-
-
Notifications
You must be signed in to change notification settings - Fork 755
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
Extra <body> node and ignored <script> with hook uponSanitizeElement #199
Comments
Ah, that's the old problem with the browser moving SCRIPT, STYLE and others into the HEAD element when not prepended by any other element. This is causing trouble in many situations. Technically not our fault but I feel more and more we should fix this. How do you feel about a |
Very interesting. Question: if |
We use the The idea is now to pre-fill the body with a nonsense element, then initialize the document, then remove the nonsense element again - all behind the suggested |
Would the proposed fix work for you? |
Yes, If I create a simple
And if I load it in the browser and look at the DOM, I obtain:
Because the callback starts at Now, if I create a simple
I get the same behavior, the An alternative approach would be to call |
We thought about that initially but I think the changes would be too disruptive. I'll see that I get an implementation of |
@jfparadis Check out the latest commits in the master branch. This should eliminate the problem. tests are green as well. |
A few notes:
Well done! |
Thanks, my pleasure :) |
Two issues with hook uponSanitizeElement:
Calling sanitize causes one extra callback, aways with extra node.
Example:
<div><script>alert(0)</script></div>
Hook called 4 times:
BODY, DIV, SCRIPT, text
When sanitizing string containing only <script> tag, there is no callback for script.
Example:
<script>alert(0)</script>
Hook called 1 time:
BODY
Please see this: JSFiddle.
The text was updated successfully, but these errors were encountered: