Skip to content
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

How to sanitize HTML for passing it to 'dangerouslySetInnerHTML' #2711

Closed
hugzug opened this issue Aug 5, 2017 · 1 comment
Closed

How to sanitize HTML for passing it to 'dangerouslySetInnerHTML' #2711

hugzug opened this issue Aug 5, 2017 · 1 comment

Comments

@hugzug
Copy link

hugzug commented Aug 5, 2017

I tried to sanitize HTML in the following JSX code:

<div dangerouslySetInnerHTML={{ __html: cleanHTML }}></div>

with DOMPurify module but it's not isomorphic so it didn't work for both client and server-side rendering. Any solution?

@timneutkens
Copy link
Member

Something like https://www.npmjs.com/package/html-escape might work. This is not a Next.js issue 😄

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants