Max Kirillov <[EMAIL PROTECTED]> writes:
> On Thu, Jun 21, 2007 at 08:14:07PM +0100, Andrew M. Bishop wrote:
> > WWWOFFLE cannot just match '</script>' within a quoted
> > string as being the end of a script because it might not
> > be.
>
> I think this is wrong. Not read standards yet, but, by pure
> thinking, js syntax must not be a part of html syntax, it is
> just encapsulated in a text node. And html syntax does not
> have quoted strings.
>
> This doc:
> ---------------
> <html>
> <script>
> alert("</script>");
> </script>
> </html>
> ---------------
>
> caused "unterminated string literal" error in the js console
> in firefox.
What did it show in the browser? Did the characters after the
</script> tag '");' show up or not?
Your example in Firefox proves that at least one version of one web
browser will terminate the script parsing when it sees "</script>".
Unfortunately it isn't proof that every browser does the same thing.
Max Kirillov <[EMAIL PROTECTED]> writes in another e-mail:
> http://www.w3.org/TR/html4/appendix/notes.html#notes-specifying-data
-------------------- HTML 4 Specification --------------------
When script or style data is the content of an element (SCRIPT and
STYLE), the data begins immediately after the element start tag and
ends at the first ETAGO ("</") delimiter followed by a name start
character ([a-zA-Z]); note that this may not be the element's end
tag. Authors should therefore escape "</" within the content. Escape
mechanisms are specific to each scripting or style sheet
language.
-------------------- HTML 4 Specification --------------------
The problem with this is that this rule applies to people writing HTML
(and specifically HTML4) and not to programs that parse HTML. I know
for a fact that there are scripts that contain "</" within quoted
strings. Terminating the script when one is seen (as described above)
would therefore not work, and probably work less often than leaving
things as they are.
Terminating the parsing when seeing the end of the script tag (and
only for this specific tag) would certainly make sense and would make
the parsing simpler.
--
Andrew.
----------------------------------------------------------------------
Andrew M. Bishop [EMAIL PROTECTED]
http://www.gedanken.demon.co.uk/
WWWOFFLE users page:
http://www.gedanken.demon.co.uk/wwwoffle/version-2.9/user.html