Hi,
using HTML 4.01 (not xhtml), I have recently discovered that this:
<script>var x='</script>';</script>
is not valid HTML - the fact that there is an end script tag in quotes
causes the parser to stop recognising the script. initially my reaction was
that this is not a surprise because I had failed to HTML encode the script
contents, so my second attempt was this:
<script>var x='</script>';</script>
however this it DOES NOT WORK - the variable ends up containing the text
"</script>"
can someone point me at part of the w3c specification that states how script
tags are parsed differently to other tags in HTML.
interestingly i have also discovered that this:
<script>if (3<5);</script>
IS valid html (and seems even to be valid XHTML) even though it is not valid
XML
Andy
using HTML 4.01 (not xhtml), I have recently discovered that this:
<script>var x='</script>';</script>
is not valid HTML - the fact that there is an end script tag in quotes
causes the parser to stop recognising the script. initially my reaction was
that this is not a surprise because I had failed to HTML encode the script
contents, so my second attempt was this:
<script>var x='</script>';</script>
however this it DOES NOT WORK - the variable ends up containing the text
"</script>"
can someone point me at part of the w3c specification that states how script
tags are parsed differently to other tags in HTML.
interestingly i have also discovered that this:
<script>if (3<5);</script>
IS valid html (and seems even to be valid XHTML) even though it is not valid
XML
Andy
Comment