fix: fix the error message

Fix the unreadable error messages with html characters.

Closes-Bug: #2023627
Change-Id: I06d09327d1423578efafc8e51107acb4025e992b
This commit is contained in:
Jingwei.Zhang 2023-06-13 14:44:48 +08:00
parent eedea3eccd
commit 38c2939d65
3 changed files with 10 additions and 1 deletions

View File

@ -60,6 +60,7 @@
"escape-html": "^1.0.3",
"file-saver": "^2.0.2",
"history": "4.7.2",
"html-entities": "^2.3.5",
"intersection-observer": "^0.11.0",
"intl-messageformat": "7.8.4",
"invariant": "^2.2.4",

View File

@ -27,6 +27,7 @@ import globalRootStore from 'stores/root';
import { unescapeHtml } from 'utils/index';
import { statusMap } from 'src/utils/code';
import { isEmpty, isString } from 'lodash';
import { decode } from 'html-entities';
import styles from './index.less';
const open = (args) => {
@ -140,6 +141,8 @@ const errorWithDetail = (err, title) => {
nTitle += statusMap[status];
}
} else {
const decodeErr =
err && isString(err) ? decode(err, { level: 'html5' }) : err;
// prettier-ignore
description = err
? <ModalButton
@ -151,7 +154,7 @@ const errorWithDetail = (err, title) => {
component={
<CodeEditor
className={styles['code-editor']}
value={err}
value={decodeErr}
mode="json"
options={{
readOnly: true,

View File

@ -7680,6 +7680,11 @@ html-entities@^2.1.0:
resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.3.2.tgz#760b404685cb1d794e4f4b744332e3b00dcfe488"
integrity sha512-c3Ab/url5ksaT0WyleslpBEthOzWhrjQbg75y7XUsfSzi3Dgzt0l8w5e7DylRn15MTlMMD58dTfzddNS2kcAjQ==
html-entities@^2.3.5:
version "2.3.5"
resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.3.5.tgz#9f117bf6a5962efc31e094f6c6dad3cf3b95e33e"
integrity sha512-72TJlcMkYsEJASa/3HnX7VT59htM7iSHbH59NSZbtc+22Ap0Txnlx91sfeB+/A7wNZg7UxtZdhAW4y+/jimrdg==
html-escaper@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453"