-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Parser throws an error if CSS parsing fails #125
Comments
Thanks for opening this issue @linkelvin11 The error you see is expected behavior since this parser does not handle sanitization of invalid HTML or CSS (see FAQ). Take a look at #124 to see some examples of how to sanitize the markup before parsing. I also created a Repl.it that fixes your example using sanitize-html. |
Ah ok, I had missed that section of the FAQ. I was able to find a Thanks! |
Hello @linkelvin11, Can you share that sanitize-html config ? Does it keep styling when it's valid or ? Thank you :) |
I used the allow all config specified in the sanitize-html docs. https://www.npmjs.com/package/sanitize-html#what-if-i-want-to-allow-all-tags-or-all-attributes |
Expected Behavior
The parsing error should be caught and handled.
Actual Behavior
html-react-parser
throws an error and JS execution stops.Steps to Reproduce
Attempt to parse a tag with an invalid style attribute.
The CSS parser should throw an error:
Example HTML string:
<p style="font-family: &quot; franklin gothic itc&quot;,helvetica,arial,sans-serif;">test</p>
Reproducible Demo
Repl.it: https://repl.it/repls/WhitesmokeAggravatingScandisk
The text was updated successfully, but these errors were encountered: