-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sanitize HTML content #205
Comments
|
@tnhu Using |
@jaywcjlove import ReactMarkdownPreview from '@uiw/react-markdown-preview'
const source = `<div onmouseover="alert('alpha')">
<a href="jAva script:alert('bravo')">delta</a>
<img src="x" onerror="alert('charlie')">
<iframe src="javascript:alert('delta')"></iframe>
<math>
<mi xlink:href="data:x,<script>alert('echo')</script>"></mi>
</math>
</div>
<script>
require('child_process').spawn('echo', ['hack!']);
</script>`
...
<ReactMarkdownPreview source={source} skipHtml /> --> |
You can try it here - https://codesandbox.io/s/floral-leaf-s0t7hm?file=/src/App.js |
@tnhu https://codesandbox.io/embed/uiwjs-react-markdown-preview-issues-205-kl1xdq?fontsize=14&hidenavigation=1&theme=dark import MarkdownPreview from "@uiw/react-markdown-preview";
const source = `<div onmouseover="alert('alpha')">
<a href="jAva script:alert('bravo')">delta</a>
<img src="x" onerror1="alert('charlie')">
<iframe src="javascript:alert('delta')"></iframe>
<math>
<mi xlink:href="data:x,<script>alert('echo')</script>"></mi>
</math>
</div>
<script>
require('child_process').spawn('echo', ['hack!']);
</script>`;
export default function App() {
return (
<div className="App">
<MarkdownPreview
source={source}
skipHtml={false}
/>
</div>
);
} |
@tnhu Upgrade |
@jaywcjlove it works. Thank you very much! Just to add a little more:
|
react-markdown-preview/src/index.tsx Lines 82 to 89 in de60a85
@tnhu Parse html by default This is because I have many projects using this package, Keep the original features.
|
react-markdown-preview
does not sanitize HTML content before rendering. Paste below code into https://uiwjs.github.io/react-markdown-preview and you'll see an alert showing up.Maybe https://github.com/rehypejs/rehype-sanitize should be included?
The text was updated successfully, but these errors were encountered: