Bug in HTML 4.01 Test: JavaScript is checked?

Dear Sir or Madam.

I think I have found a bug in the validator check tool.

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! It has no line breaks to make it a bit more complex.

Now, let's put the code into a valid (X-)HTML page and check it with W3C-Validator.

When checked as XHTML 1.0 Transitional: Valid!
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!

So, what can I do, that my HTML 4.01 document is detected as valid? Or is it a bug of W3C that should be solved?

Best regards,
Daniel Marschall

Received on Wednesday, 18 February 2009 14:19:34 UTC