This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 4999 - Validator fails to detect and report id selector starting with hyphen followed by a digit
Summary: Validator fails to detect and report id selector starting with hyphen followe...
Status: RESOLVED FIXED
Alias: None
Product: CSSValidator
Classification: Unclassified
Component: CSS 2.1 (show other bugs)
Version: CSS Validator
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: qa-dev tracking
URL: http://www.gtalbot.org/BrowserBugsSec...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-01 03:40 UTC by Gérard Talbot
Modified: 2009-02-10 14:20 UTC (History)
0 users

See Also:


Attachments

Description Gérard Talbot 2007-09-01 03:40:15 UTC
CSS validator, profile 2.1, incorrectly reports validity for case of id selector starting with hyphen followed by a digit.

Steps to reproduce
------------------
1. Load provided URL
2. Submit to CSS validator (profile CSS 2.1) :
http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.gtalbot.org%2FBrowserBugsSection%2FMSIE7Bugs%2FHyphenFollowedByADigitInIdentifiers.html&warning=2&profile=css21&usermedium=all
or just click the CSS button in that page

Actual results
--------------
CSS validator reports 
Your stylesheet validated (French: "Votre feuille de style CSS validée") :

#-2bar, .two {
color : red;
background-color : white;
}

Expected results
----------------
The CSS validator should detect the id selector starting with an hyphen followed by a digit and then reject the css rule based on known parsing rules and report a parse error for that css rule.

References
----------

CSS 2.1, Section 4.1.3 Characters and case (identifiers) says:
"in CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-z0-9] and ISO 10646 characters U+00A1 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, or a hyphen followed by a digit."
http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier

CSS 2.1, Section 4.1.1 tokenization 
http://www.w3.org/TR/CSS21/syndata.html#tokenization
and 
CSS 2.1, G.2 Lexical scanner 
http://www.w3.org/TR/CSS21/grammar.html#scanner
both gives
ident -?{nmstart}{nmchar}*
nmstart [_a-z]|{nonascii}|{escape}

Please note that I reported this issue at bugzilla.mozilla.org 
https://bugzilla.mozilla.org/show_bug.cgi?id=12385
and at bugzilla.webkit.org
http://bugs.webkit.org/show_bug.cgi?id=14373
Comment 1 Gérard Talbot 2007-09-03 21:42:56 UTC
Same findings with one testpage of the latest (August 4th 2007) CSS 2.1 testsuite:

URL: http://www.w3.org/Style/CSS/Test/CSS2.1/current/html4/t040103-ident-03-c.htm

CSS validation: 
http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.w3.org%2FStyle%2FCSS%2FTest%2FCSS2.1%2Fcurrent%2Fhtml4%2Ft040103-ident-03-c.htm&warning=1&profile=css21&usermedium=all

Returned result from CSS validator reporting "Valid CSS Information":

#-1ident, .four {
color : red;
}

(...)

.-1ident, .five {
color : green;
} 

In both cases, the selectors starting with hyphen followed with a digit should be detected, rejected and reported as parse errors.
Comment 2 Yves Lafon 2009-02-06 16:57:43 UTC
In

#-1ident, .four {
color : red;
}

#-1ident matches the HASH production which is defined as # <NAME>
(see "#"{name}	{return HASH;} in http://www.w3.org/TR/CSS21/grammar.html )
or name is defined by {nmchar}+ containing [0-9], so it is correct according t the grammar. I will check with the CSS WG.

Comment 3 Yves Lafon 2009-02-10 14:20:29 UTC
Fixed on http://qa-dev.w3.org:8001/css-validator/