Skip to content

Commit 1733d5b

Browse files
committed
doc: update document. (#249)
1 parent d680e3e commit 1733d5b

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

core/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,33 @@ export default function Demo() {
316316
}
317317
```
318318

319+
## Security
320+
321+
Please note markdown needs to be sanitized if you do not completely trust your authors. Otherwise, your app is vulnerable to XSS. This can be achieved by adding [rehype-sanitize](https://github.com/rehypejs/rehype-sanitize) as a plugin.
322+
323+
```jsx mdx:preview&checkered=0
324+
import React from 'react';
325+
import rehypeSanitize from "rehype-sanitize";
326+
import MarkdownPreview from '@uiw/react-markdown-preview';
327+
328+
const source = `
329+
## MarkdownPreview
330+
331+
**Hello world!!!** <IFRAME SRC=\"javascript:javascript:alert(window.origin);\"></IFRAME>
332+
333+
<!-- test --> 123
334+
335+
<!-- test --> 456 <!-- test -->
336+
`;
337+
338+
const rehypePlugins = [rehypeSanitize];
339+
export default function Demo() {
340+
return (
341+
<MarkdownPreview source={source} rehypePlugins={rehypePlugins} />
342+
)
343+
}
344+
```
345+
319346
### Options Props
320347

321348
```typescript

website/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"mermaid": "^10.4.0",
1414
"react": "~18.2.0",
1515
"react-dom": "~18.2.0",
16-
"react-router-dom": "^6.8.1"
16+
"react-router-dom": "^6.8.1",
17+
"rehype-sanitize": "^6.0.0"
1718
},
1819
"devDependencies": {
1920
"@kkt/less-modules": "^7.4.7",

0 commit comments

Comments
 (0)