Bug 36515 - CSS style definitions are ignored if they just follow a "@charset" which appears in lines other than the first line in stylesheet.
Summary: CSS style definitions are ignored if they just follow a "@charset" which appe...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Alexey Proskuryakov
URL: http://bbs.club.sina.com.cn/group.php...
Keywords:
: 44857 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-03-23 19:23 PDT by Hanrui
Modified: 2011-04-04 07:01 PDT (History)
8 users (show)

See Also:


Attachments
testcase 1 (383 bytes, text/html)
2010-03-23 19:23 PDT, Hanrui
no flags Details
testcase 2 (256 bytes, text/html)
2010-03-23 19:23 PDT, Hanrui
no flags Details
proposed fix (4.47 KB, patch)
2010-08-30 14:14 PDT, Alexey Proskuryakov
darin: review+
commit-queue: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hanrui 2010-03-23 19:23:35 PDT
Created attachment 51474 [details]
testcase 1

Browsers tested:
Safari 4.0.5(531.22.7): Fail
      Chrome 5.0.342.3: Fail
           Firefox 3.6: OK
                  IE 7: OK
                  IE 8: OK (In IE 8, it runs in IE7 Standards mode by page default)

What steps will reproduce the problem?
1. Launch the url in each browser
2. Pay attention to the top area of the page

What is the expected result?
Chrome and Safari should better show the same UI as that in IE and Firefox.

What happens instead?
In Chrome and Safari, the page loses the '新浪论坛' icon at the top-left 
side and shows the top login area is in a different color from that in IE 
and Firefox.

Please provide any additional information below. Attach a screenshot if
possible.

Thy this page: http://bbs.club.sina.com.cn/group.php?gid=26&tree=1
In its css file(http://sjs.sinajs.cn/tiezi/css/bbs2/dev.css?38.css), there 
are more than one "charset" lines. All style definition right following the 
charset lines will be missed expect the first charset line.
Yes, this issue is caused by mis-using of "charset", but why could not we 
handle it correctly while IE and Firefox both can?
Attached please kindly find my recuded test-case.
In my first test-case, the 2nd and 3rd selectors are both ignored in Safari 
and Chrome. But they are having effect in Firefox and IE.
And in the second test-case, you will see that the first selector which 
just follows the '@charset' right in the first line take effect while the 
second selector doesn't.
Thanks!
Comment 1 Hanrui 2010-03-23 19:23:56 PDT
Created attachment 51475 [details]
testcase 2
Comment 2 Jungshik Shin 2010-03-23 21:10:25 PDT
It's reported in Chromiub bug tracker (http://crbug.com/38877 )
Comment 3 Alexey Proskuryakov 2010-03-24 21:16:53 PDT
See also: bug 18265. Seems that Firefox behavior is not what we thought it was.
Comment 4 Adam Barth 2010-03-25 16:10:51 PDT
I'm not 100% clear on the expected behavior here.  Should we be ignoring these @charset directives or should we be switching charsets as we go?
Comment 5 Alexey Proskuryakov 2010-03-25 17:10:19 PDT
The spec just says that such stylesheets are invalid, so all we can do is check other browsers' behavior.

My guess is that no browser switches the encoding. They may ignore misplaced charset declarations, or they may honor the first, or the last. The first option (ignoring) seems best and most likely to me in the absence of hard facts.
Comment 6 Guido Jansen 2010-08-06 08:07:24 PDT
(In reply to comment #5)
> The spec just says that such stylesheets are invalid, so all we can do is check other browsers' behavior.
> 
> My guess is that no browser switches the encoding. They may ignore misplaced charset declarations, or they may honor the first, or the last. The first option (ignoring) seems best and most likely to me in the absence of hard facts.

in
http://www.w3.org/TR/CSS21/syndata.html#charset
it says 
"User agents must ignore any @charset rule not at the beginning of the style sheet."
Comment 7 Alexey Proskuryakov 2010-08-30 10:18:34 PDT
*** Bug 44857 has been marked as a duplicate of this bug. ***
Comment 8 Alexey Proskuryakov 2010-08-30 10:19:18 PDT
See also: bug 21628.
Comment 9 Alexey Proskuryakov 2010-08-30 14:14:30 PDT
Created attachment 65952 [details]
proposed fix
Comment 10 WebKit Commit Bot 2010-08-31 00:22:44 PDT
Comment on attachment 65952 [details]
proposed fix

Rejecting patch 65952 from commit-queue.

Failed to run "['WebKitTools/Scripts/run-webkit-tests', '--no-launch-safari', '--exit-after-n-failures=1', '--wait-for-httpd', '--ignore-tests', 'compositing,media', '--quiet']" exit_code: 1
Running build-dumprendertree
Compiling Java tests
make: Nothing to be done for `default'.
Running tests from /Users/eseidel/Projects/CommitQueue/LayoutTests
Testing 20871 test cases.
fast/loader/recursive-before-unload-crash.html -> failed

Exiting early after 1 failures. 14296 tests run.
254.34s total testing time

14295 test cases (99%) succeeded
1 test case (<1%) had incorrect layout
1 test case (<1%) had stderr output

Full output: http://queues.webkit.org/results/3881178
Comment 11 Adam Barth 2010-08-31 00:26:03 PDT
Comment on attachment 65952 [details]
proposed fix

Sorry, that's a top flaky test.
Comment 12 WebKit Commit Bot 2010-08-31 02:33:50 PDT
Comment on attachment 65952 [details]
proposed fix

Rejecting patch 65952 from commit-queue.

Failed to run "[u'git', u'svn', u'dcommit']" exit_code: 1
Last 500 characters of output:
ced-charset.html
	M	WebCore/ChangeLog
	M	WebCore/css/CSSGrammar.y
A repository hook failed: MERGE request failed on '/repository/webkit/trunk': Commit blocked by pre-commit hook (exit code 1) with output:

    The following files contain tab characters:

        trunk/LayoutTests/fast/css/misplaced-charset.html

    Please use spaces instead to indent.
    If you must commit a file with tabs, use svn propset to set the "allow-tabs" property.
 at /usr/local/git/libexec/git-core/git-svn line 572


Full output: http://queues.webkit.org/results/3856188
Comment 13 Alexey Proskuryakov 2010-08-31 08:50:12 PDT
Committed <http://trac.webkit.org/changeset/66486>.