Re: Validator error

"Michael[tm] Smith" <[email protected]> Mon, 10 Nov 2014 12:07:24 +0900
Newsgroups gmane.org.w3c.validator
Message-ID <[email protected]>
Hi Jukka,

> Date: Mon, 27 Oct 2014 00:29:57 +0200
> From: "Jukka K. Korpela" <[email protected]>
> Archived-At: <http://www.w3.org/mid/[email protected]>
...
> The culprit appears to be on line 48:
> 
> 		&lt;p&gt;10 строка | &w3 &lt;/p&gt;
> 
> Validating this line in isolation, with a minimal document around it,
> results in a correct message that points to the “&w3” construct.
> 
> The bug in the validator is that it does not report this properly at
> all in the given context but instead flags completely correct
> character references *before* it as erroneous.
> 
> The bug is reproducible at http://validator.nu too.

Thanks for examining this, and thanks to Roman for reporting it. It's
definitely a bug.

The message is this case is coming from the HTML parser but I can't
reproduce it in "View source" in Firefox (which uses the same HTML parser):

  view-source:http://websnippets.ru/article.php?id=30
  (mouse over the "&w3")

...so it seems a problem specific to the validator usage of the HTML parser.

This is minimally reproducible with the following document:

  <!doctype html><title>test</title>&gt;<textarea>&w3</textarea>

  http://validator.w3.org/nu/?showsource=yes&doc=data%3Atext%2Fhtml%3Bcharset%3Dutf-8%2C%3C%2521doctype%2520html%3E%3Ctitle%3Etest%3C%252Ftitle%3E%2526gt%253B%3Ctextarea%3E%2526w3%3C%252Ftextarea%3E

If you replace the `texarea` with a `span` or whatever, you can't reproduce
it. That makes some sense because the `textarea` elements have special code
path in the parser, along with `title` elements.

So I kinda expect the core problem here is, the validator code isn't
passing on line-number info correctly to the parser when processing
`textarea` and `title` elements. Here's an even more minimal case:

  <!doctype html><title>&w3</title>

  http://validator.w3.org/nu/?showsource=yes&doc=data%3Atext%2Fhtml%3Bcharset%3Dutf-8%2C%3C%2521doctype%2520html%3E%3Ctitle%3E%2526w3%3C%252Ftitle%3E

For that case, the validator just reports "Error: & did not start a
character reference. (& probably should have been escaped as &amp;.)",
without reporting line+col numbers at all or flagging the position.

So I think the root cause of the problem Roman ran into is that the
validator doesn't have any line-number info to report in this case, and
then the parser's character-reference reporting isn't getting
re-initialized correctly, so it reports the position of the last character
reference it checked that did have a line+col numbers.

Anyway, I've filed a bug http://bugzilla.validator.nu/show_bug.cgi?id=1010
and I'll try to make some time soon to investigate the code around this.

  --Mike

-- 
Michael[tm] Smith https://people.w3.org/mike
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAEBCgAGBQJUYCvsAAoJEIfRdHe8OkuVcbQQAKhITHOmnx1ddkiBvTluHPR+
RuDvIzYxu5hViXQjXEcgMg04cxwIDotXrfYTlpDKSFemNwTdRUFXlGWfP+S4F7/6
ZQlD8BZ86wbTDwgJltwOhFCkVT8cud2ekDvT3cWocQV5jPzYb8KrtNR2gRMx6jS3
pq1anTCBJeYibJm3yrfz8D74AW9q+aKb2kJEb0zN9OjaXF2Pe5xPdeQIvfUH5rVv
pt1J6aY+qhO1W6P0vHsNVEqguCbHJJ60ftZTkhXHbhJgxx7S6zwss+5Bz5taXd7b
HTL1AnSn1F/GSKJNjsYdz25Rp5zHZ9dPjR/2c+h2teHigPHI0FzDtY4WKw/wYU1v
z5mmozEGCRwh2WortjaIfsXchssl1MRyx65Z+owkIMu0YtG8y3sYeD84rFzxkx2/
ymG/g/nF/k3ky60dHMziqc80GX/I5/APY2Iwth/7roSdv0LxHXa370ZaVKdAtNxI
w+OVAz5xYDNZByJ6W7w7KL9lRmsHmf0PNvihNHWFoipCsK5QMllICNyrye8bV64h
rpOWZr4nhNx+IlGsdljtZn6PwF3mT2s0SOdsLAESZuJFX4UzTJKyn+dyCmwsdpLz
FWJG5UuqLRsn3HT/DMqp8tUWunuPN5B0iXULZwb109/KnS5vam5MrvBhdxYg5+Hi
n4DwPtehxKqaNIhQ6Ut2
=510i
-----END PGP SIGNATURE-----