W3C home > Mailing lists > Public > public-html-comments@w3.org > April 2010

Re: Restrictions for contents of script elements

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 13 Apr 2010 20:03:42 +0000 (UTC)
To: Julien Royer <eldebaran@gmail.com>
Cc: public-html-comments@w3.org
Message-ID: <Pine.LNX.4.64.1004131953040.751@ps20323.dreamhostps.com>
On Tue, 13 Apr 2010, Julien Royer wrote:
> I don't understand the restrictions defined for the content of script 
> elements: 
> http://dev.w3.org/html5/spec/semantics.html#restrictions-for-contents-of-script-elements
> script being a raw-text element, it can't contain the "script-end" 
> production 
> (http://www.w3.org/TR/html5/syntax.html#cdata-rcdata-restrictions).
> Why do we need such a complex ABNF for the content of script elements?

Unfortunately for historical reasons the parsing rules for <script> blocks 
are really obscure and can lead to some really strange results. For 

 "<script><script></script>" closes at the </script>
 "<script><!--</script>" closes at the </script>
 "<script><!--<script></script></script>" closes at the _second_ </script>

Since we're basically stuck living with these silly rules (they're needed 
to parse legacy documents), we have the complex ABNF you refer to to 
prevent authors from trying to write stuff that doesn't work right.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 13 April 2010 20:04:11 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:26:26 UTC