Menu

#268 Incorrect parsing of script with regexps

open
nobody
5
2009-01-30
2009-01-30
cvanderlaan
No

When parsing the following script, Lexer.parseCDATA(true) interprets the quote in the inline regexp /'/ as starting a string that is closed by the quote before '</div>'.

<script>
var content = "<div>";
content += document.title.replace(/'/g,"&rsquo;") ;
content += '</div>';
</script>

The following </ token then closes the script prematurely:

<script>
var content = "<div>";
content += document.title.replace(/'/g,"&rsquo;") ;
content += '</script></div>

Discussion


Log in to post a comment.