Skip to content

Commit 0e17991

Browse files
committed
feat: add rehype-sanitize to protect markdown html from xss
1 parent 8e593f7 commit 0e17991

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

client/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"react-virtualized-auto-sizer": "^1.0.7",
7373
"react-virtuoso": "^4.4.0",
7474
"rehype-raw": "^6.1.1",
75+
"rehype-sanitize": "^6.0.0",
7576
"remark-gfm": "^3.0.1",
7677
"socket.io-client": "^4.6.1",
7778
"source-ref-runtime": "^1.0.7",

client/web/src/components/Markdown/render.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { isValidStr, parseUrlStr, useTranslation } from 'tailchat-shared';
44
import { Loadable } from '../Loadable';
55
import { Image } from 'tailchat-design';
66
import remarkGfm from 'remark-gfm';
7-
// import rehypeRaw from 'rehype-raw';
8-
// import rehypeSanitize from 'rehype-sanitize';
7+
import rehypeRaw from 'rehype-raw';
8+
import rehypeSanitize from 'rehype-sanitize';
99
import './render.less';
1010

1111
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -82,7 +82,7 @@ export const Markdown: React.FC<{
8282
transformImageUri={(src) => transformUrl(src)}
8383
transformLinkUri={(href) => transformUrl(href)}
8484
remarkPlugins={[remarkGfm]}
85-
// rehypePlugins={[rehypeRaw, rehypeSanitize]}
85+
rehypePlugins={[rehypeRaw, rehypeSanitize]}
8686
linkTarget="_blank"
8787
skipHtml={true}
8888
components={components}

pnpm-lock.yaml

Lines changed: 38 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)