W3C home > Mailing lists > Public > www-validator@w3.org > February 2009

Re: Bug in HTML 4.01 Test: JavaScript is checked?

From: David Dorward <david@dorward.me.uk>
Date: Wed, 18 Feb 2009 14:48:52 +0000
Message-ID: <499C1FD4.6070507@dorward.me.uk>
To: Daniel Marschall <info@daniel-marschall.de>
CC: www-validator@w3.org
Daniel Marschall wrote:  
> I made a Anti-Spam-Mechanism which outputs following html code:
>  
> <script language="JavaScript" type="text/javascript"><!--
> document.write("<a 
> href=\"");document.write("&#109;");document.write("&#97;");document.write("&#105;");document.write("&#108;");document.write("&#116;");document.write("&#111;");document.write("&#58;");document.write("&#105;");document.write("&#110;");document.write("&#102;");document.write("&#111;");document.write("&#64;");document..write("&#101;");document.write("&#120;");document.write("&#97;");document.write("&#109;");document.write("&#112;");document.write("&#108;");document.write("&#101;");document.write("&#46;");document.write("&#99;");document.write("&#111;");document.write("&#109;");document.write("\">");document.write("&#105;");document.write("&#110;");document.write("&#102;");document.write("&#111;");document.write("&#64;");document.write("&#101;");document.write("&#120;");document.write("&#97;");document.write("&#109;");document.write("&#112;");document.write("&#108;");document.write("&#101;");document.write("&#46;");document.write("&#99;");document.write("&#111;");document.write("&#109;");document.write("</a>");// 
> --></script>
>  
> Note: This is a JavaScript, it should be ignored by the validator!
No. It is some code that appears between <script> and </script>. It 
shouldn't be ignored by the validator, it should be processed as the 
content of the script element requires.
> When checked as XHTML 1.0 Transitional: Valid!
But pointless, since all the code is commented out: 
http://dorward.me.uk/www/comments-cdata/

> When checked an HTML 4.01 Transitional: NOT valid!
>  
> It says, that the closed Tag </a> was not opened. But this </a> is 
> inside the <!-- and --> because of the JavaScript! So, it should not 
> be an error!
<script> elements in HTML are marked as containing CDATA, so <!-- and 
--> are not comments. See http://dorward.me.uk/www/comments-cdata/ and 
the document the validator pointed you towards when it reported that error:

  """
      If this error occurred in a script section of your document, you 
should probably read this FAQ entry 
<http://validator.w3.org/docs/help.html#faq-javascript>.
   """

http://validator.w3.org/docs/help.html#faq-javascript

-- 
David Dorward
Received on Wednesday, 18 February 2009 14:49:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:34 GMT