Bug 23744 - stylesheet not applied because css file not parsed correctly if it contains comments and charset
Summary: stylesheet not applied because css file not parsed correctly if it contains c...
Status: RESOLVED DUPLICATE of bug 18265
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://csdraveurs.qc.ca/
Keywords: HasReduction
: 23947 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-04 14:45 PST by jasneet
Modified: 2009-10-16 12:07 PDT (History)
4 users (show)

See Also:


Attachments
testcase (895 bytes, application/zip)
2009-02-04 14:48 PST, jasneet
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description jasneet 2009-02-04 14:45:50 PST
I Steps:
Go to http://csdraveurs.qc.ca/

II Issue:
left navigation bar links have extra scroll bars

III Conclusion:
The issue is caused by the css file not being applied correctly because of the 
/*comment*/ and @charset in its contents. The css file looks like: 

/* Définition de règle */
@charset "iso-8859-1";
.leftframe {color: 0067c6; font-family:  "Times New Roman", Times, serif; font-size: 
10px; font-weight: bold; line-height: normal; text-align: center}

IV Other Browsers:
IE7: ok
FF3: ok

V Nightly tested: 40471

Bug in Chromium : http://code.google.com/p/chromium/issues/detail?id=5771
Comment 1 jasneet 2009-02-04 14:48:14 PST
Created attachment 27330 [details]
testcase
Comment 2 Alexey Proskuryakov 2009-02-15 01:44:19 PST
This is broken CSS - "@charset" should be the first bytes in file, except for BOM. But obviously, we should be more forgiving for compatibility with other browsers.

One thing we should test for is whether this charset is honored, or just ignored.
Comment 3 Taruchhaya 2009-02-20 05:07:04 PST
I have done some analysis on this bug.My observations are:

1) "leftframe.css" :: Issue is caused by the css file not being applied correctly because of the /*comment*/ and @charset in its contents. The css file looks like: 
/* Dfinition de rgle */
@charset "iso-8859-1";
.leftframe {color: 0067c6; font-family: "Times New Roman", Times, serif;
font-size: 10px; font-weight: bold; line-height: normal; text-lign: center}

Reason::The @charset At-Rule is allowed to occur only once in an external style sheet and it must be the very first statement in the style sheet. 

QUERIES:
1) "/*comment*/" is a valid CSS statement, which is escaped/ignored while executing the code. So shouldn't the same approach be followed in this case and @charset should be considered/honored.

While debugging the Grammar.y, I found that "/*comment*/" is not the issue. The issue is in "/r" & "/n" after the comment, which is forcing the parser to consider the rest of the document as an invalid rule.

2) I also found another issue in this bug,i.e. in "Link Tag".
Reason:: In Safari, Link Tag is not able to open/recognize the externally linked CSS file. 
As, HTML document contains the following snippet for link tag:
<link href="leftframe.css" rel="stylesheet" type="text/css">
<link href="../leftframe.css" rel="stylesheet" type="text/css"> 

Here, In second link statement: "../leftframe.css" is invalid because it is trying to access the .css file from the root level, which is not available, webkit should check this condition and then resolve it by appending to the base URI just like how IE does.

Please provide me some suggestions on the above issues.

Comment 4 Alexey Proskuryakov 2009-02-20 05:19:08 PST
(In reply to comment #3)
> 2) I also found another issue in this bug,i.e. in "Link Tag".

Please file a new bug for this new issue.
Comment 5 Taruchhaya 2009-02-22 20:51:10 PST
 Raised the new Bug ID: 24084:: "Link Tag" issue
Comment 6 Alexey Proskuryakov 2009-04-08 01:59:09 PDT
See also: bug 18265 (@charset in inline CSS).
Comment 7 Alexey Proskuryakov 2009-04-08 02:28:22 PDT
*** Bug 23947 has been marked as a duplicate of this bug. ***
Comment 8 Adam Barth 2009-10-16 12:07:53 PDT
This is the same a Bug 18265 because the comment get stripped out by the tokenizer.

*** This bug has been marked as a duplicate of bug 18265 ***