The problem reported in problem 175375 was not a complete description. Using the small example referenced in the 175375 shows the following: <script> document.write("Before test<br>"); document.write("<script></script>"); document.write("<br>After test"); </script> This problem eas reported as failing in Mozilla and new NS but not in NS4.79. A true example of the condition is: <script> document.write("Before test<br>"); <!-- document.write("<script></script>"); //--> document.write("<br>After test"); </script> This code does work in 4.79 as the comments hide the unescaped </string> as listed in the HTML4.01 spec under section 18.3.2 "Hiding script data from user agents" There is also a compatability section we at found http://www.w3.org/TR/xhtml1/#C_4. Section "C.4. Embedded Style Sheets and Scripts" warns of new browsers stripping the comment tags away and exposing the hidden scripts. This implies section 18 is not valid in the latest version. It seems this particular difference is in NS 6.0, 6.1, 7.0, Mozilla 1.01, Mozilla 1.1. But the NS release of NS6.2, NS6.2.2, NS6.2.3 let the code work the same way as in NS 4.79. Can someone please explain if this is a bug in the browser, if not can you point to where it is documented that this is invalid coding to rely on the comment tags to hide the unescaped </script> tag. Thanks.
http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.1 says that the contents of a <script> element must be %Script; http://www.w3.org/TR/html401/sgml/dtd.html#Script says that %Script; means "CDATA". In CDATA, all chars are treated literally. Thus markup is not treated as markup in CDATA. Comments are markup. The comment trick is meant for _old_ browsers which do not know what the <script> element is and hence do not know that it should only contain CDATA and that the text in it should not be rendered.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID
Component: DOM: HTML → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.