W3C home > Mailing lists > Public > www-validator-css@w3.org > August 2006

Re: Validator incorrectly reports validity for case of illegal escaped newline (but only in certain cases)

From: Bert Bos <bert@w3.org>
Date: Tue, 22 Aug 2006 14:38:27 +0200
To: www-validator-css@w3.org
Message-Id: <200608221438.27620.bert@w3.org>

> I believe that the following CSS fragment is illegal, if my reading of
> CSS 2.1 and CSS 2 is correct, yet the validator reports no error. 
>
> --
> Test case:
>
>         element {color : red;  }\
>
> IMPORTANT NOTE: to reproduce this defect, note the following
> conditions: (i) a newline must be inserted immediately after the
> backslash, and (ii) it is important that there be no other characters
> at all following the newline. Test case checked using direct input
> mode, grammar CSS2 selected.
> -- 
>
> Reasoning: the escaped newline is only legal inside a string, if my
> reading is correct. See the productions for "string1"/"string2" in
> CSS2 section D.2.
>
> (An aside; FYI: note that the example
>         element {color : red;  }\
>         a {}
> is rejected, which is as it should be.)

Yes, I think it's a validator bug.

A backslash-escape can only occur in a string or in an identifier. In 
this case it's not a string, so it must be an identifier. In other 
words, the backslash+newline (let's assume the newline is a line-feed, 
but carriage return would be analogous) represents the start of an 
identifier with a line-feed as the first character, the same as "\0A 
a".

That's a strange kind of identifier, not one you would find in SGML or 
XML, but legal in CSS. And thus the validator should report an 
incomplete rule.

Your second example is also a bug, because backslash+newline+a is a 
valid selector (albeit for an element name that cannot occur in XML) 
and should not produce an error. (A warning is maybe in order, because 
it is unlikely that the author really intended this element name.)



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Tuesday, 22 August 2006 12:40:50 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 27 June 2012 00:14:17 GMT