fix: purify html before render

This commit is contained in:
Steven 2024-06-04 23:10:54 +08:00
parent 2b49025f4a
commit e8ed437ca3
3 changed files with 87 additions and 62 deletions

View file

@ -21,6 +21,7 @@
"clsx": "^2.1.1",
"copy-to-clipboard": "^3.3.3",
"dayjs": "^1.11.11",
"dompurify": "^3.1.5",
"fuse.js": "^7.0.0",
"highlight.js": "^11.9.0",
"i18next": "^23.11.5",

View file

@ -10,10 +10,10 @@ importers:
dependencies:
'@dnd-kit/core':
specifier: ^6.1.0
version: 6.1.0(react-dom@18.3.1)(react@18.3.1)
version: 6.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@dnd-kit/sortable':
specifier: ^8.0.0
version: 8.0.0(@dnd-kit/core@6.1.0)(react@18.3.1)
version: 8.0.0(@dnd-kit/core@6.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
'@dnd-kit/utilities':
specifier: ^3.2.2
version: 3.2.2(react@18.3.1)
@ -22,7 +22,7 @@ importers:
version: 11.11.4(@types/react@18.3.3)(react@18.3.1)
'@emotion/styled':
specifier: ^11.11.5
version: 11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1)
version: 11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)
'@github/relative-time-element':
specifier: ^4.4.0
version: 4.4.0
@ -31,10 +31,10 @@ importers:
version: 3.1.3(katex@0.16.10)(react@18.3.1)
'@mui/joy':
specifier: 5.0.0-beta.36
version: 5.0.0-beta.36(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)
version: 5.0.0-beta.36(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@reduxjs/toolkit':
specifier: ^2.2.4
version: 2.2.5(react-redux@9.1.2)(react@18.3.1)
version: 2.2.5(react-redux@9.1.2(@types/react@18.3.3)(react@18.3.1)(redux@5.0.1))(react@18.3.1)
clsx:
specifier: ^2.1.1
version: 2.1.1
@ -44,6 +44,9 @@ importers:
dayjs:
specifier: ^1.11.11
version: 1.11.11
dompurify:
specifier: ^3.1.5
version: 3.1.5
fuse.js:
specifier: ^7.0.0
version: 7.0.0
@ -73,19 +76,19 @@ importers:
version: 18.3.1(react@18.3.1)
react-hot-toast:
specifier: ^2.4.1
version: 2.4.1(csstype@3.1.3)(react-dom@18.3.1)(react@18.3.1)
version: 2.4.1(csstype@3.1.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
react-i18next:
specifier: ^14.1.1
version: 14.1.2(i18next@23.11.5)(react-dom@18.3.1)(react@18.3.1)
version: 14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
react-redux:
specifier: ^9.1.2
version: 9.1.2(@types/react@18.3.3)(react@18.3.1)(redux@5.0.1)
react-router-dom:
specifier: ^6.23.1
version: 6.23.1(react-dom@18.3.1)(react@18.3.1)
version: 6.23.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
react-use:
specifier: ^17.5.0
version: 17.5.0(react-dom@18.3.1)(react@18.3.1)
version: 17.5.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
tailwindcss:
specifier: ^3.4.3
version: 3.4.3
@ -97,7 +100,7 @@ importers:
version: 9.0.1
zustand:
specifier: ^4.5.2
version: 4.5.2(@types/react@18.3.3)(react@18.3.1)
version: 4.5.2(@types/react@18.3.3)(immer@10.1.1)(react@18.3.1)
devDependencies:
'@bufbuild/buf':
specifier: ^1.32.1
@ -137,13 +140,13 @@ importers:
version: 9.0.8
'@typescript-eslint/eslint-plugin':
specifier: ^7.8.0
version: 7.11.0(@typescript-eslint/parser@7.11.0)(eslint@8.57.0)(typescript@5.4.5)
version: 7.11.0(@typescript-eslint/parser@7.11.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5)
'@typescript-eslint/parser':
specifier: ^7.10.0
version: 7.11.0(eslint@8.57.0)(typescript@5.4.5)
'@vitejs/plugin-react':
specifier: ^4.3.0
version: 4.3.0(vite@5.2.12)
version: 4.3.0(vite@5.2.12(@types/node@20.14.0)(less@4.2.0))
autoprefixer:
specifier: ^10.4.19
version: 10.4.19(postcss@8.4.38)
@ -155,7 +158,7 @@ importers:
version: 9.1.0(eslint@8.57.0)
eslint-plugin-prettier:
specifier: ^5.1.3
version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.3.0)
version: 5.1.3(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.3.0)
eslint-plugin-react:
specifier: ^7.34.1
version: 7.34.2(eslint@8.57.0)
@ -3265,7 +3268,7 @@ snapshots:
react: 18.3.1
tslib: 2.6.2
'@dnd-kit/core@6.1.0(react-dom@18.3.1)(react@18.3.1)':
'@dnd-kit/core@6.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
dependencies:
'@dnd-kit/accessibility': 3.1.0(react@18.3.1)
'@dnd-kit/utilities': 3.2.2(react@18.3.1)
@ -3273,9 +3276,9 @@ snapshots:
react-dom: 18.3.1(react@18.3.1)
tslib: 2.6.2
'@dnd-kit/sortable@8.0.0(@dnd-kit/core@6.1.0)(react@18.3.1)':
'@dnd-kit/sortable@8.0.0(@dnd-kit/core@6.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)':
dependencies:
'@dnd-kit/core': 6.1.0(react-dom@18.3.1)(react@18.3.1)
'@dnd-kit/core': 6.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@dnd-kit/utilities': 3.2.2(react@18.3.1)
react: 18.3.1
tslib: 2.6.2
@ -3324,9 +3327,10 @@ snapshots:
'@emotion/use-insertion-effect-with-fallbacks': 1.0.1(react@18.3.1)
'@emotion/utils': 1.2.1
'@emotion/weak-memoize': 0.3.1
'@types/react': 18.3.3
hoist-non-react-statics: 3.3.2
react: 18.3.1
optionalDependencies:
'@types/react': 18.3.3
'@emotion/serialize@1.1.4':
dependencies:
@ -3338,7 +3342,7 @@ snapshots:
'@emotion/sheet@1.2.2': {}
'@emotion/styled@11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1)':
'@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)':
dependencies:
'@babel/runtime': 7.24.6
'@emotion/babel-plugin': 11.11.0
@ -3347,8 +3351,9 @@ snapshots:
'@emotion/serialize': 1.1.4
'@emotion/use-insertion-effect-with-fallbacks': 1.0.1(react@18.3.1)
'@emotion/utils': 1.2.1
'@types/react': 18.3.3
react: 18.3.1
optionalDependencies:
'@types/react': 18.3.3
'@emotion/unitless@0.8.1': {}
@ -3461,7 +3466,7 @@ snapshots:
'@floating-ui/core': 1.6.2
'@floating-ui/utils': 0.2.2
'@floating-ui/react-dom@2.1.0(react-dom@18.3.1)(react@18.3.1)':
'@floating-ui/react-dom@2.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
dependencies:
'@floating-ui/dom': 1.6.5
react: 18.3.1
@ -3514,82 +3519,88 @@ snapshots:
katex: 0.16.10
react: 18.3.1
'@mui/base@5.0.0-beta.42(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)':
'@mui/base@5.0.0-beta.42(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
dependencies:
'@babel/runtime': 7.24.6
'@floating-ui/react-dom': 2.1.0(react-dom@18.3.1)(react@18.3.1)
'@floating-ui/react-dom': 2.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@mui/types': 7.2.14(@types/react@18.3.3)
'@mui/utils': 6.0.0-dev.20240529-082515-213b5e33ab(@types/react@18.3.3)(react@18.3.1)
'@popperjs/core': 2.11.8
'@types/react': 18.3.3
clsx: 2.1.1
prop-types: 15.8.1
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
optionalDependencies:
'@types/react': 18.3.3
'@mui/core-downloads-tracker@6.0.0-dev.240424162023-9968b4889d': {}
'@mui/joy@5.0.0-beta.36(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)':
'@mui/joy@5.0.0-beta.36(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
dependencies:
'@babel/runtime': 7.24.6
'@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1)
'@emotion/styled': 11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1)
'@mui/base': 5.0.0-beta.42(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)
'@mui/base': 5.0.0-beta.42(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@mui/core-downloads-tracker': 6.0.0-dev.240424162023-9968b4889d
'@mui/system': 6.0.0-dev.240424162023-9968b4889d(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.3.3)(react@18.3.1)
'@mui/system': 6.0.0-dev.240424162023-9968b4889d(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)
'@mui/types': 7.2.14(@types/react@18.3.3)
'@mui/utils': 6.0.0-dev.20240529-082515-213b5e33ab(@types/react@18.3.3)(react@18.3.1)
'@types/react': 18.3.3
clsx: 2.1.1
prop-types: 15.8.1
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
optionalDependencies:
'@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1)
'@emotion/styled': 11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)
'@types/react': 18.3.3
'@mui/private-theming@6.0.0-dev.20240529-082515-213b5e33ab(@types/react@18.3.3)(react@18.3.1)':
dependencies:
'@babel/runtime': 7.24.6
'@mui/utils': 6.0.0-dev.20240529-082515-213b5e33ab(@types/react@18.3.3)(react@18.3.1)
'@types/react': 18.3.3
prop-types: 15.8.1
react: 18.3.1
optionalDependencies:
'@types/react': 18.3.3
'@mui/styled-engine@6.0.0-dev.20240529-082515-213b5e33ab(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(react@18.3.1)':
'@mui/styled-engine@6.0.0-dev.20240529-082515-213b5e33ab(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(react@18.3.1)':
dependencies:
'@babel/runtime': 7.24.6
'@emotion/cache': 11.11.0
'@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1)
'@emotion/styled': 11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1)
csstype: 3.1.3
prop-types: 15.8.1
react: 18.3.1
optionalDependencies:
'@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1)
'@emotion/styled': 11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)
'@mui/system@6.0.0-dev.240424162023-9968b4889d(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.3.3)(react@18.3.1)':
'@mui/system@6.0.0-dev.240424162023-9968b4889d(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)':
dependencies:
'@babel/runtime': 7.24.6
'@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1)
'@emotion/styled': 11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1)
'@mui/private-theming': 6.0.0-dev.20240529-082515-213b5e33ab(@types/react@18.3.3)(react@18.3.1)
'@mui/styled-engine': 6.0.0-dev.20240529-082515-213b5e33ab(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(react@18.3.1)
'@mui/styled-engine': 6.0.0-dev.20240529-082515-213b5e33ab(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(react@18.3.1)
'@mui/types': 7.2.14(@types/react@18.3.3)
'@mui/utils': 6.0.0-dev.20240529-082515-213b5e33ab(@types/react@18.3.3)(react@18.3.1)
'@types/react': 18.3.3
clsx: 2.1.1
csstype: 3.1.3
prop-types: 15.8.1
react: 18.3.1
optionalDependencies:
'@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1)
'@emotion/styled': 11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)
'@types/react': 18.3.3
'@mui/types@7.2.14(@types/react@18.3.3)':
dependencies:
optionalDependencies:
'@types/react': 18.3.3
'@mui/utils@6.0.0-dev.20240529-082515-213b5e33ab(@types/react@18.3.3)(react@18.3.1)':
dependencies:
'@babel/runtime': 7.24.6
'@types/prop-types': 15.7.12
'@types/react': 18.3.3
prop-types: 15.8.1
react: 18.3.1
react-is: 18.3.1
optionalDependencies:
'@types/react': 18.3.3
'@nodelib/fs.scandir@2.1.5':
dependencies:
@ -3633,14 +3644,15 @@ snapshots:
'@protobufjs/utf8@1.1.0': {}
'@reduxjs/toolkit@2.2.5(react-redux@9.1.2)(react@18.3.1)':
'@reduxjs/toolkit@2.2.5(react-redux@9.1.2(@types/react@18.3.3)(react@18.3.1)(redux@5.0.1))(react@18.3.1)':
dependencies:
immer: 10.1.1
react: 18.3.1
react-redux: 9.1.2(@types/react@18.3.3)(react@18.3.1)(redux@5.0.1)
redux: 5.0.1
redux-thunk: 3.1.0(redux@5.0.1)
reselect: 5.1.1
optionalDependencies:
react: 18.3.1
react-redux: 9.1.2(@types/react@18.3.3)(react@18.3.1)(redux@5.0.1)
'@remix-run/router@1.16.1': {}
@ -3899,7 +3911,7 @@ snapshots:
'@types/uuid@9.0.8': {}
'@typescript-eslint/eslint-plugin@7.11.0(@typescript-eslint/parser@7.11.0)(eslint@8.57.0)(typescript@5.4.5)':
'@typescript-eslint/eslint-plugin@7.11.0(@typescript-eslint/parser@7.11.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5)':
dependencies:
'@eslint-community/regexpp': 4.10.1
'@typescript-eslint/parser': 7.11.0(eslint@8.57.0)(typescript@5.4.5)
@ -3912,6 +3924,7 @@ snapshots:
ignore: 5.3.1
natural-compare: 1.4.0
ts-api-utils: 1.3.0(typescript@5.4.5)
optionalDependencies:
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
@ -3924,6 +3937,7 @@ snapshots:
'@typescript-eslint/visitor-keys': 7.11.0
debug: 4.3.5
eslint: 8.57.0
optionalDependencies:
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
@ -3940,6 +3954,7 @@ snapshots:
debug: 4.3.5
eslint: 8.57.0
ts-api-utils: 1.3.0(typescript@5.4.5)
optionalDependencies:
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
@ -3956,6 +3971,7 @@ snapshots:
minimatch: 9.0.4
semver: 7.6.2
ts-api-utils: 1.3.0(typescript@5.4.5)
optionalDependencies:
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
@ -3978,7 +3994,7 @@ snapshots:
'@ungap/structured-clone@1.2.0': {}
'@vitejs/plugin-react@4.3.0(vite@5.2.12)':
'@vitejs/plugin-react@4.3.0(vite@5.2.12(@types/node@20.14.0)(less@4.2.0))':
dependencies:
'@babel/core': 7.24.6
'@babel/plugin-transform-react-jsx-self': 7.24.6(@babel/core@7.24.6)
@ -4642,13 +4658,14 @@ snapshots:
dependencies:
eslint: 8.57.0
eslint-plugin-prettier@5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.3.0):
eslint-plugin-prettier@5.1.3(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.3.0):
dependencies:
eslint: 8.57.0
eslint-config-prettier: 9.1.0(eslint@8.57.0)
prettier: 3.3.0
prettier-linter-helpers: 1.0.0
synckit: 0.8.8
optionalDependencies:
eslint-config-prettier: 9.1.0(eslint@8.57.0)
eslint-plugin-react@7.34.2(eslint@8.57.0):
dependencies:
@ -5409,7 +5426,7 @@ snapshots:
object-assign: 4.1.1
thenify-all: 1.6.0
nano-css@5.6.1(react-dom@18.3.1)(react@18.3.1):
nano-css@5.6.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
dependencies:
'@jridgewell/sourcemap-codec': 1.4.15
css-tree: 1.1.3
@ -5570,8 +5587,9 @@ snapshots:
postcss-load-config@4.0.2(postcss@8.4.38):
dependencies:
lilconfig: 3.1.1
postcss: 8.4.38
yaml: 2.4.3
optionalDependencies:
postcss: 8.4.38
postcss-nested@6.0.1(postcss@8.4.38):
dependencies:
@ -5633,7 +5651,7 @@ snapshots:
react: 18.3.1
scheduler: 0.23.2
react-hot-toast@2.4.1(csstype@3.1.3)(react-dom@18.3.1)(react@18.3.1):
react-hot-toast@2.4.1(csstype@3.1.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
dependencies:
goober: 2.1.14(csstype@3.1.3)
react: 18.3.1
@ -5641,12 +5659,13 @@ snapshots:
transitivePeerDependencies:
- csstype
react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1)(react@18.3.1):
react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
dependencies:
'@babel/runtime': 7.24.6
html-parse-stringify: 3.0.1
i18next: 23.11.5
react: 18.3.1
optionalDependencies:
react-dom: 18.3.1(react@18.3.1)
react-is@16.13.1: {}
@ -5655,15 +5674,16 @@ snapshots:
react-redux@9.1.2(@types/react@18.3.3)(react@18.3.1)(redux@5.0.1):
dependencies:
'@types/react': 18.3.3
'@types/use-sync-external-store': 0.0.3
react: 18.3.1
redux: 5.0.1
use-sync-external-store: 1.2.2(react@18.3.1)
optionalDependencies:
'@types/react': 18.3.3
redux: 5.0.1
react-refresh@0.14.2: {}
react-router-dom@6.23.1(react-dom@18.3.1)(react@18.3.1):
react-router-dom@6.23.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
dependencies:
'@remix-run/router': 1.16.1
react: 18.3.1
@ -5680,7 +5700,7 @@ snapshots:
react: 18.3.1
tslib: 2.6.2
react-use@17.5.0(react-dom@18.3.1)(react@18.3.1):
react-use@17.5.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
dependencies:
'@types/js-cookie': 2.2.7
'@xobotyi/scrollbar-width': 1.9.5
@ -5688,7 +5708,7 @@ snapshots:
fast-deep-equal: 3.1.3
fast-shallow-equal: 1.0.0
js-cookie: 2.2.1
nano-css: 5.6.1(react-dom@18.3.1)(react@18.3.1)
nano-css: 5.6.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
react-universal-interface: 0.6.2(react@18.3.1)(tslib@2.6.2)
@ -6121,13 +6141,13 @@ snapshots:
vite@5.2.12(@types/node@20.14.0)(less@4.2.0):
dependencies:
'@types/node': 20.14.0
esbuild: 0.20.2
less: 4.2.0
postcss: 8.4.38
rollup: 4.18.0
optionalDependencies:
'@types/node': 20.14.0
fsevents: 2.3.3
less: 4.2.0
void-elements@3.1.0: {}
@ -6201,8 +6221,10 @@ snapshots:
yocto-queue@0.1.0: {}
zustand@4.5.2(@types/react@18.3.3)(react@18.3.1):
zustand@4.5.2(@types/react@18.3.3)(immer@10.1.1)(react@18.3.1):
dependencies:
'@types/react': 18.3.3
react: 18.3.1
use-sync-external-store: 1.2.0(react@18.3.1)
optionalDependencies:
'@types/react': 18.3.3
immer: 10.1.1
react: 18.3.1

View file

@ -1,5 +1,6 @@
import clsx from "clsx";
import copy from "copy-to-clipboard";
import DOMPurify from "dompurify";
import hljs from "highlight.js";
import { useCallback, useMemo } from "react";
import toast from "react-hot-toast";
@ -23,7 +24,8 @@ const CodeBlock: React.FC<Props> = ({ language, content }: Props) => {
// Users can set Markdown code blocks as `__html` to render HTML directly.
if (formatedLanguage === SpecialLanguage.HTML) {
return <div className="w-full overflow-auto !my-2" dangerouslySetInnerHTML={{ __html: content }} />;
const purify = DOMPurify(window);
return <div className="w-full overflow-auto !my-2" dangerouslySetInnerHTML={{ __html: purify.sanitize(content) }} />;
} else if (formatedLanguage === SpecialLanguage.MERMAID) {
return <MermaidBlock content={content} />;
}