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 2920 - Several invalid forms using @charset passed as valid
Summary: Several invalid forms using @charset passed as valid
Status: RESOLVED FIXED
Alias: None
Product: CSSValidator
Classification: Unclassified
Component: CSS 2.0 (show other bugs)
Version: CSS Validator
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: qa-dev tracking
URL:
Whiteboard: http 404 Fichier non trouv
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-22 22:35 UTC by CecilWard
Modified: 2008-03-08 00:02 UTC (History)
0 users

See Also:


Attachments
test case 1 (108 bytes, text/css)
2008-03-07 23:23 UTC, Olivier Thereaux
Details
test case 2 (122 bytes, text/css)
2008-03-07 23:23 UTC, Olivier Thereaux
Details
test case 3 (109 bytes, text/css)
2008-03-07 23:24 UTC, Olivier Thereaux
Details
test case 4 (112 bytes, text/css)
2008-03-07 23:24 UTC, Olivier Thereaux
Details
test case 5 (110 bytes, text/css)
2008-03-07 23:24 UTC, Olivier Thereaux
Details
test case 6 (110 bytes, text/css)
2008-03-07 23:25 UTC, Olivier Thereaux
Details
test case 7 (113 bytes, text/css)
2008-03-07 23:25 UTC, Olivier Thereaux
Details

Description CecilWard 2006-02-22 22:35:15 UTC
The CSS validator passes the following with no error,

Test case 1.
    @charset"utf-8";

(spec requires a space before open quotes)


Test case 2.
    @charset              "utf-8";

(spec requires exactly 1 space before opening double quotes)


Test case 3.
    @charset
    "utf-8";

(newline instead of space)

Test case 4.
    @charset/**/"utf-8";

Test case 5.
    @charset "utf-8" ;

(illegal space before semicolon)

Test case 6.
    @charset "utf-8"
    ;

(illegal newline before semicolon)

Test case 7:
    /**/@charset "utf-8";


Regards,

Cecil Ward.
Comment 1 Bj 2006-02-23 04:52:12 UTC
I assume with "the spec" you mean the CSS 2.1 Working Draft? CSS 2.1 changed 
the rules for this and the CSS Validator predates those draft rules...
Comment 2 CecilWard 2006-04-21 15:40:55 UTC
(In reply to comment #1)
> I assume with "the spec" you mean the CSS 2.1 Working Draft? CSS 2.1 changed 
> the rules for this and the CSS Validator predates those draft rules...

Good point. Indeed, I was looking at CSS 2.1. But my point stands, because even if you explicitly set the validator to use CSS 2.1, it passes all the above. (I just rechecked.) So it basically can not validate against the 2.1 grammar.

As for CSS2.0 (if you like0, I would need to look at the test cases again with CSS2.0 eyes. But presumably having something that is valid only against CSS2.0 but is not actually going to work in (any? some?) browsers isn't useful. Maybe the validator should issue a warning about certain highly questionable forms of css if the user explicitly selects CSS2.0.

A further point. If the user has not specified a version of CSS, and the various grammars are in conflict, in the sense that what the user has entered is legal in one version of CSS but illegal in another, then maybe the best thing to do would be to warn the user rather than just saying "valid!" which is meaningless and sort-of dangerous.

Suggestion: In the case where the user does not pick as CSS version one possible improvement would be to parse the user's CSS fragment multiple times against the various grammars and if there are both passes and fails, tell the user the details. Warnings about lack of backwards- or forwards capability would be a valuable added benefit of using the validator.
Comment 3 CecilWard 2006-04-21 17:23:18 UTC
Having taken another look, from a CSS2.0 standpoint

CSS 2 section 4.4 states

"@charset rule [...] must appear at the very start of the document, not preceded by any characters".

So by this paragraph, the validator should report an error in the case where some whitespace and/or a comment, say, precedes the @charset. This is a fault. Because of the restrictive specification of @charset, the CSS validator is not at liberty to pre-strip all comments or strip whitespace in an initial phase before doing futher syntactical analysis. Looking at the output displayed in the case of an error suggests that it may pre-strip comments.

As for the CSS2 documents, the restriction expressed in that English sentence is not reflected in the example formal grammar in the CSS2 appendix D, which is too lax.

Comment 4 Olivier Thereaux 2007-01-19 03:40:39 UTC
(removing spam)
Comment 5 CecilWard 2007-10-23 21:26:50 UTC
As far as I can see all of the above test cases 1-7 are now fixed. We can close this.

However, in for example, test case 1 now correctly reports failure, apart from if CSS1 is selected, when it seems to fall over (error message looks strange).

Some of the other test cases produce the same weird error if CSS1 is selected. I haven't gone through them all (yet).


Comment 6 Olivier Thereaux 2008-03-07 23:23:28 UTC
Created attachment 528 [details]
test case 1
Comment 7 Olivier Thereaux 2008-03-07 23:23:49 UTC
Created attachment 529 [details]
test case 2
Comment 8 Olivier Thereaux 2008-03-07 23:24:13 UTC
Created attachment 530 [details]
test case 3
Comment 9 Olivier Thereaux 2008-03-07 23:24:35 UTC
Created attachment 531 [details]
test case 4
Comment 10 Olivier Thereaux 2008-03-07 23:24:52 UTC
Created attachment 532 [details]
test case 5
Comment 11 Olivier Thereaux 2008-03-07 23:25:17 UTC
Created attachment 533 [details]
test case 6
Comment 12 Olivier Thereaux 2008-03-07 23:25:43 UTC
Created attachment 534 [details]
test case 7
Comment 13 Olivier Thereaux 2008-03-08 00:02:20 UTC
Thanks Cecil for the test cases. I added them into the test suite to make sure we don't have any regression in the future.