<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>8852</bug_id>
          
          <creation_ts>2010-02-01 04:48:28 +0000</creation_ts>
          <short_desc>HTML4 validator doesn&apos;t accept &lt;![CDATA[ &lt;tag&gt;&lt;/tag&gt; ]]&gt; inside the &lt;script&gt; element</short_desc>
          <delta_ts>2010-03-21 15:03:18 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Validator</product>
          <component>Parser</component>
          <version>HEAD</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P1</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Leif Halvard Silli">xn--mlform-iua</reporter>
          <assigned_to name="This bug has no owner yet - up for the taking">dave.null</assigned_to>
          <cc>xn--mlform-iua</cc>
          
          <qa_contact name="qa-dev tracking">www-validator-cvs</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>31377</commentid>
    <comment_count>0</comment_count>
    <who name="Leif Halvard Silli">xn--mlform-iua</who>
    <bug_when>2010-02-01 04:48:28 +0000</bug_when>
    <thetext>The HTML4 validator doesn&apos;t accept the following &lt;script&gt; example as validating HTML4 code (while Validator.nu accepts it as validating HTML5 ...)

&lt;script type=&quot;text/javascript&quot;&gt;&lt;![CDATA[
    document.write(&quot;&lt;aa&gt;&lt;bb&gt;&lt;/bb&gt;&lt;/aa&gt;&quot;);
]]&gt;&lt;/script&gt;

In comparison, the following *does* validate as HTML4 (while Validator.nu *doesn&apos;t* accept it as HTML5):

&lt;p&gt;&lt;![CDATA[
&lt;aa&gt;&lt;bb&gt;&lt;/bb&gt;&lt;/aa&gt;
]]&gt;&lt;/p&gt;

Both of code examples should be stamped as validating HTML4 code! 

According to the spec ( http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.5 ) then HTML4 does include support for marked sections for CDATA content. Marked CDATA sections permits authors to skip using escape tags: &lt;![[CDATA[  &lt;tag&gt;marked section&lt;/tag&gt;  ]]&gt;.

If one wants to create polyglot JavaScript scripts for use both in HTML4 as well as XHTML documents, then it is crucial that the validator gives correct information w.r.t.  the validity of &lt;![CDATA[ ... ]]&gt;, since &lt;![CDATA[ ...]]&gt; sections are needed in order to embed scripts in XHTML.  The current validator bug makes it seem unneccessary difficult to create &quot;polyglot scripts&quot;.

Some background to explain a possible counter argument:

Section 18.2.4 of HTML4 (http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.4) gives an scripting example where the end tag &quot;&lt;/b&gt;&quot; inside the script  element has been escaped with the backslash character: &quot;&lt;\/b&gt;&quot;. This has been done in order  that the code doesn&apos;t break the SGML parsing rules, according to which the first occurrence of &quot;&lt;/&quot; would have had implications.

The code example in section 18.2.4 is supposed to examplify what is said in the preceding text:

]]
HTML documents are constrained to conform to the HTML DTD both before and after processing any SCRIPT elements.
[[


However, it is not expressed anywhere that one cannot use the &lt;![CDATA[ ... ]]&gt; construct  in HTML4 documents!  In XHTML it is customary to precede the start and end &quot;tag&quot; of the CDATA section with a Javascript escape code - for example like the following - in order to be both valid from the XHTML angle and from the JavaScript angle. For example, it can be done like this:

&lt;script type=&quot;text/javascript&quot;&gt;//&lt;![CDATA[
    document.write(&quot;&lt;aa&gt;&lt;bb&gt;&lt;/bb&gt;&lt;/aa&gt;&quot;);
//]]&gt;&lt;/script&gt;

And this should clearly not be stamped as invalid HTML4 code either!  (Sidenote: The script doesn&apos;t appear to run in Internet Explorer (version 6 at least) and also not in Webkit, if  the first content of the script element is a &quot;&lt;![CDATA[ &quot;, so there are several reasons to do the escaping.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33740</commentid>
    <comment_count>1</comment_count>
    <who name="Leif Halvard Silli">xn--mlform-iua</who>
    <bug_when>2010-03-21 15:03:18 +0000</bug_when>
    <thetext>I realize that this bug, after all, was invalid. Sorry.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>