Bug 18604 - Backslash escape (\) for splitting CSS rules into a couple of lines fails in WebKit
Summary: Backslash escape (\) for splitting CSS rules into a couple of lines fails in ...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://www.hixie.ch/tests/evil/css/cs...
Keywords: HasReduction
Depends on:
Blocks:
 
Reported: 2008-04-18 17:55 PDT by jasneet
Modified: 2012-09-27 19:44 PDT (History)
4 users (show)

See Also:


Attachments
minimal test case (369 bytes, application/xhtml+xml)
2008-06-02 04:20 PDT, Robert Blaut
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description jasneet 2008-04-18 17:55:34 PDT
I Steps:
Go to 
http://www.hixie.ch/tests/evil/css/css21/contributions/incoming/00003.xht

II Issue:
The text appears red instead of green as backslash parsing fails.

III Conclusion:
issue with backslash parsing

IV Other browsers:
IE7: not ok; link does not open
FF3: ok
Opera9.24: ok

V Nightly tested: 32005

Another link with same issue: 
http://www.hixie.ch/tests/evil/css/css21/contributions/incoming/00006.xht 
(this test passes in Opera)
Comment 1 Robert Blaut 2008-06-02 04:19:29 PDT
I can confirm the bug. It violates the definition of CSS 2.1 CR:
"It is possible to break strings over several lines, for esthetic or other reasons, but in such a case the newline itself has to be escaped with a backslash (\). For instance, the following two selectors are exactly the same:

a[title="a not s\
o very long title"] {/*...*/}
a[title="a not so very long title"] {/*...*/}" [http://www.w3.org/TR/CSS21/syndata.html#strings]
Comment 2 Robert Blaut 2008-06-02 04:20:01 PDT
Created attachment 21458 [details]
minimal test case
Comment 3 Alexey Proskuryakov 2010-02-16 19:08:24 PST
See also: bug 28885.
Comment 4 Glenn Adams 2012-09-27 19:44:06 PDT
the analysis of this bug is incorrect; in particular, the attached test case and the test from hixie cited below [1] contain a backslash that is OUTSIDE of a string, and NOT in a string;

[1] http://www.hixie.ch/tests/evil/css/css21/contributions/incoming/00003.xht

the text cited below in comment #1 refers to backslash appearing IN a string; the more complete, relevant text from CSS 2.1 is found in Section 4.1.3 [2] which states:

"First, inside a string, a backslash followed by a newline is ignored (i.e., the string is deemed not to contain either the backslash or the newline). Outside a string, a backslash followed by a newline stands for itself (i.e., a DELIM followed by a newline)."

[2] http://www.w3.org/TR/CSS2/syndata.html

so, in fact, the backslash followed by newline that appears in these tests should be treated as the token sequence <DELIM NL>

according to the general grammar in [3], DELIM matches the 'any' non-terminal, so the attached test should parse as two consecutive rulesets:

ruleset <= 'h1 {background: white; color: red}'
ruleset <= '\ zzz, h1 {color: green}'

where in the second ruleset the selector non-terminal matches DELIM IDENT DELIM IDENT

[3] http://www.w3.org/TR/CSS2/syndata.html#tokenization

now, however, the more restrictive grammar in Appendix G [4] does not admit backslash or DELIM as a token in a selector, so consequently, the second ruleset fails to match the selector non-terminal, and thus the entire second statement is treated as a malformed statement and ignored [5]

[4] http://www.w3.org/TR/CSS2/grammar.html
[5] http://www.w3.org/TR/CSS2/syndata.html#parsing-errors

i checked both Opera and FF and both behave the same as WK