Re: css identifier parsing bugs, escapes in classnames

From: "Daniel W. Connolly" <connolly@w3.org>
Date: Wed, Jul 19, 2000, 12:54 AM

> The text of the paragraph in the following document
> should be purple, no?
>
> --8<--8<--
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <title>test</title>
> <style type="text/css">
> p.a\:b { color: purple }
> </style>
> </head>
> <body>
> <p class="a:b">aslkfj</p>
> </body>
> </html>
> --8<--8<--

Yes, it should be purple.

> HTML 4 doesn't exactly say what the syntax of a class name
> is:
>
> "class = cdata-list [CS]
>                 This attribute assigns a class name or set of class names
> to an element. Any number of elements may be assigned
>                 the same class name or names. Multiple class names must be
> separated by white space characters. "
>
>   -- http://www.w3.org/TR/html4/struct/global.html#adef-class

cdata without an explicit restriction means that ":" is a perfectly
legitimate character to include.

> but the CSS specs are pretty clear that identifiers can
> contain excape gizmos:
>
> "In CSS2, identifiers (including element names, classes, and IDs in
> selectors) can contain only the characters [A-Za-z0-9] and
>       ISO 10646 characters 161 and higher, plus the hyphen (-); they cannot
> start with a hyphen or a digit. They can also contain
>       escaped characters and any ISO 10646 character as a numeric code (see
> next item). For instance, the identifier "B&W?" may
>       be written as "B\&W\?" or "B\26 W\3F".  "
>
>  -- http://www.w3.org/TR/REC-CSS2/syndata.html#keywords

Yes.

> I don't see a relevant test in the test suite.
>  http://www.w3.org/Style/CSS/Test/
>
> Please add one.

Not a bad idea.

> Are there *any* implementations that get the identifier
> parsing in CSS right? I tried Netscape 4 and IE 4
> and Opera 4 and Amaya and they all failed.
>
> I can see that the relevant Amaya code doesn't implement
> the escape codes: the only occurrence of '\' in
> the code is to handle strings.
> http://dev.w3.org/cvsweb/Amaya/amaya/styleparser.c
>  1.59 Tue Jun 27 11:19:46 2000 UTC
>
> Ah... flute seems to grok.
>
> http://dev.w3.org/cvsweb/java/classes/org/w3c/flute/parser/Parser.jj
> 1.12 Wed Apr 19 21:59:52 2000 UTC

IE5.0/Mac handles your test case correctly.

Tantek

----------------------------------------------------------------------------
It is not the spoon that bends, it is only yourself.   microsoft.com/mac/ie/

Received on Wednesday, 26 July 2000 03:07:23 UTC