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

<script> tags not handled correctly if nested in other tags #12

Open
steffenweber opened this issue Oct 18, 2012 · 1 comment
Open

<script> tags not handled correctly if nested in other tags #12

steffenweber opened this issue Oct 18, 2012 · 1 comment

Comments

@steffenweber
Copy link
Contributor

I've found yet another crappy ad with a script tag that does not exist at the top-level but inside another tag.

Test case:

<!DOCTYPE html>
<html>
<body>

<div id="placeholder"></div>
<script src="/clientscripts/crapLoader.js"></script>
<script>crapLoader.loadScript('./crap-ad.js', 'placeholder');</script>

</body>
</html>

crap-ad.js:

document.write('<div><scr'+'ipt>var x = 1;</scr'+'ipt><span>HTML</span><'+'/div>');

The correct output (without crapLoader) is:

<div><span>HTML</span></div>

With crapLoader the result is:

<div></div><span>HTML</span>

The "split" function works fine (with support.splitWithCapturingParentheses = true):

["<div>", "<script>var x = 1;</script>", "<span>HTML</span></div>"] 

The problem seems to be that later in the function "checkWriteBuffer" the HTML fragments are written to the document independently. I do not yet have an idea how to fix this issue.

[Btw, with support.splitWithCapturingParentheses = false the split does not work correctly, but that's another bug that is independent from this issue here:]

["<script>var x = 1;</script>", "<span>HTML</span></div>"]
@gregersrygg
Copy link
Owner

This one looks a bit complicated, but I have a few ideas on how to solve it. Thanks for all the details :)

gregersrygg added a commit that referenced this issue Oct 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants