Title: [134518] trunk
Revision
134518
Author
[email protected]
Date
2012-11-13 18:55:17 -0800 (Tue, 13 Nov 2012)

Log Message

CSS @charset parsing is too loose, doesn't match other browsers
https://bugs.webkit.org/show_bug.cgi?id=101527

Patch by Tab Atkins <[email protected]> on 2012-11-13
Reviewed by Alexey Proskuryakov.

Source/WebCore:

Per <https://www.w3.org/Bugs/Public/show_bug.cgi?id=19882#attach_1244>,
IE and FF have changed to be strict about @charset parsing,
as the CSS 2.1 spec requires.
Since @charset use is very uncommon anyway,
we should match the new behavior and the spec for platform consistency.

Test: fast/encoding/css-charset-evil/css-charset-evil.html

* loader/TextResourceDecoder.cpp:
(WebCore::bytesEqual):
(WebCore::TextResourceDecoder::checkForCSSCharset):

LayoutTests:

Removed the old css-charset-evil.html test,
which tested for our loose parsing of @charset.
Now that we're tightening our parsing to match the spec and IE's and FF's new behavior,
I added a more comprehensive test of incorrect @charset rules,
to ensure that we correctly reject them.

* fast/encoding/css-charset-evil-expected.txt: Removed.
* fast/encoding/css-charset-evil.css: Removed.
* fast/encoding/css-charset-evil.html: Removed.
* fast/encoding/css-charset-evil/css-charset-evil-a1.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-a2.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-a3.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-a4.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-b1.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-b2.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-b3.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-b4.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-b5.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-b6.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-b7.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-b8.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-c1.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-c2.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-c3.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-d1.css: Added.
* fast/encoding/css-charset-evil/css-charset-evil-expected.txt: Added.
* fast/encoding/css-charset-evil/css-charset-evil.html: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (134517 => 134518)


--- trunk/LayoutTests/ChangeLog	2012-11-14 02:53:24 UTC (rev 134517)
+++ trunk/LayoutTests/ChangeLog	2012-11-14 02:55:17 UTC (rev 134518)
@@ -1,3 +1,38 @@
+2012-11-13  Tab Atkins  <[email protected]>
+
+        CSS @charset parsing is too loose, doesn't match other browsers
+        https://bugs.webkit.org/show_bug.cgi?id=101527
+
+        Reviewed by Alexey Proskuryakov.
+
+        Removed the old css-charset-evil.html test,
+        which tested for our loose parsing of @charset.
+        Now that we're tightening our parsing to match the spec and IE's and FF's new behavior,
+        I added a more comprehensive test of incorrect @charset rules,
+        to ensure that we correctly reject them.
+
+        * fast/encoding/css-charset-evil-expected.txt: Removed.
+        * fast/encoding/css-charset-evil.css: Removed.
+        * fast/encoding/css-charset-evil.html: Removed.
+        * fast/encoding/css-charset-evil/css-charset-evil-a1.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-a2.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-a3.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-a4.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-b1.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-b2.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-b3.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-b4.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-b5.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-b6.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-b7.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-b8.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-c1.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-c2.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-c3.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-d1.css: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil-expected.txt: Added.
+        * fast/encoding/css-charset-evil/css-charset-evil.html: Added.
+
 2012-11-13  Thiago Marcos P. Santos  <[email protected]>
 
         [EFL] Add new baselines after r134435

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a1.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a1.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a1.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@charset "utf-8";
+#a1ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a2.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a2.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a2.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@CHARSET "utf-8";
+#a2ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a3.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a3.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a3.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@ChArSeT "utf-8";
+#a3ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a4.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a4.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-a4.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@cHaRsEt "utf-8";
+#a4ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b1.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b1.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b1.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@charset"utf-8";
+#b1ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b2.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b2.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b2.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@charset  "utf-8";
+#b2ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b3.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b3.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b3.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@charset\9"utf-8";
+#b3ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b4.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b4.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b4.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@charset\A"utf-8";
+#b4ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b5.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b5.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b5.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@charset\C"utf-8";
+#b5ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b6.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b6.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b6.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@charset\D"utf-8";
+#b6ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b7.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b7.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b7.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@charset "utf-8" ;
+#b7ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b8.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b8.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-b8.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+ @charset "utf-8";
+#b8ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-c1.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-c1.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-c1.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,2 @@
+@charset 'utf-8';
+#c1ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-c2.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-c2.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-c2.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,3 @@
+@charset "utf-8';
+#c2ä { display: inline; }
+#c2ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-c3.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-c3.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-c3.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,3 @@
+@charset 'utf-8";
+#c3ä { display: inline; }
+#c3ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-d1.css (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-d1.css	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-d1.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,3 @@
+@charset "utf-8"
+#d1ä { display: inline; }
+#d1ä { display: inline; }
\ No newline at end of file

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-expected.txt (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil-expected.txt	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,26 @@
+Correct:
+@charset "utf-8";    PASS
+
+Wrong Capitalization:
+@CHARSET "utf-8";    PASS
+@ChArSeT "utf-8";    PASS
+@cHaRsEt "utf-8";    PASS
+
+Wrong Whitespace:
+@charset"utf-8";     PASS
+@charset  "utf-8";   PASS
+@charset\9"utf-8";   PASS
+@charset\A"utf-8";   PASS
+@charset\C"utf-8";   PASS
+@charset\D"utf-8";   PASS
+@charset "utf-8" ;   PASS
+ @charset "utf-8";   PASS
+
+Wrong Quote character:
+@charset 'utf-8';    PASS
+@charset "utf-8';    PASS
+@charset 'utf-8";    PASS
+
+Wrong Semicolon:
+@charset "utf-8"     PASS
+

Added: trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil.html (0 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil.html	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil/css-charset-evil.html	2012-11-14 02:55:17 UTC (rev 134518)
@@ -0,0 +1,57 @@
+<!doctype html>
+<meta charset="us-ascii">
+<title>Test of what variations on the @charset directive are acceptable</title>
+<style>
+body { line-height: 1.5em; }
+span { display: none; padding: 2px;}
+span.pass { background: lime; color: green; }
+span.fail { background: red; color: white; }
+</style>
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<link rel=stylesheet href=""
+<pre>
+Correct:
+@charset "utf-8";    <span id="a1&#195;&#164;" class='fail'>FAIL</span><span id="a1&#228;" class='pass'>PASS</span>
+
+Wrong Capitalization:
+@CHARSET "utf-8";    <span id="a2&#195;&#164;" class='pass'>PASS</span><span id="a2&#228;" class='fail'>FAIL</span>
+@ChArSeT "utf-8";    <span id="a3&#195;&#164;" class='pass'>PASS</span><span id="a3&#228;" class='fail'>FAIL</span>
+@cHaRsEt "utf-8";    <span id="a4&#195;&#164;" class='pass'>PASS</span><span id="a4&#228;" class='fail'>FAIL</span>
+
+Wrong Whitespace:
+@charset"utf-8";     <span id="b1&#195;&#164;" class='pass'>PASS</span><span id="b1&#228;" class='fail'>FAIL</span>
+@charset  "utf-8";   <span id="b2&#195;&#164;" class='pass'>PASS</span><span id="b2&#228;" class='fail'>FAIL</span>
+@charset\9"utf-8";   <span id="b3&#195;&#164;" class='pass'>PASS</span><span id="b3&#228;" class='fail'>FAIL</span>
+@charset\A"utf-8";   <span id="b4&#195;&#164;" class='pass'>PASS</span><span id="b4&#228;" class='fail'>FAIL</span>
+@charset\C"utf-8";   <span id="b5&#195;&#164;" class='pass'>PASS</span><span id="b5&#228;" class='fail'>FAIL</span>
+@charset\D"utf-8";   <span id="b6&#195;&#164;" class='pass'>PASS</span><span id="b6&#228;" class='fail'>FAIL</span>
+@charset "utf-8" ;   <span id="b7&#195;&#164;" class='pass'>PASS</span><span id="b7&#228;" class='fail'>FAIL</span>
+ @charset "utf-8";   <span id="b8&#195;&#164;" class='pass'>PASS</span><span id="b8&#228;" class='fail'>FAIL</span>
+
+Wrong Quote character:
+@charset 'utf-8';    <span id="c1&#195;&#164;" class='pass'>PASS</span><span id="c1&#228;" class='fail'>FAIL</span>
+@charset "utf-8';    <span id="c2&#195;&#164;" class='pass'>PASS</span><span id="c2&#228;" class='fail'>FAIL</span>
+@charset 'utf-8";    <span id="c3&#195;&#164;" class='pass'>PASS</span><span id="c3&#228;" class='fail'>FAIL</span>
+
+Wrong Semicolon:
+@charset "utf-8"     <span id="d1&#195;&#164;" class='pass'>PASS</span><span id="d1&#228;" class='fail'>FAIL</span>
+</pre>
+
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+</script>
\ No newline at end of file

Deleted: trunk/LayoutTests/fast/encoding/css-charset-evil-expected.txt (134517 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil-expected.txt	2012-11-14 02:53:24 UTC (rev 134517)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil-expected.txt	2012-11-14 02:55:17 UTC (rev 134518)
@@ -1,5 +0,0 @@
-Test for bug 10155: CSS2: @charset is not supported
-
-CSS 2.1 says that @charset " must be written literally, but Firefox and IE allow extra spaces and single quotes.
-
-SUССЕSS

Deleted: trunk/LayoutTests/fast/encoding/css-charset-evil.css (134517 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil.css	2012-11-14 02:53:24 UTC (rev 134517)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil.css	2012-11-14 02:55:17 UTC (rev 134518)
@@ -1,2 +0,0 @@
-@charset	  'utf-8' 	;
-#dummy:before { content: "SUССЕSS"; }

Deleted: trunk/LayoutTests/fast/encoding/css-charset-evil.html (134517 => 134518)


--- trunk/LayoutTests/fast/encoding/css-charset-evil.html	2012-11-14 02:53:24 UTC (rev 134517)
+++ trunk/LayoutTests/fast/encoding/css-charset-evil.html	2012-11-14 02:55:17 UTC (rev 134518)
@@ -1,31 +0,0 @@
-<html>
-<head>
-    <meta content="text/html; charset=windows-1251" http-equiv="Content-Type"/>
-    <link rel="stylesheet" type="text/css" href=""
-</head>
-<body _onload_="test()">
-<p>Test for <a href="" 10155</a>:
-CSS2: @charset is not supported</p>
-
-<p>CSS 2.1 says that <code>@charset "</code> must be written literally, 
-but Firefox and IE allow extra spaces and single quotes.</p>
-
-<p id="result"></p>
-
-<script>
-if (window.testRunner)
-    testRunner.dumpAsText();
-
-function test() {
-  try {
-    text = document.styleSheets[0].rules[0].style.getPropertyValue("content");
-    text = text.replace(/"/g, "");
-    document.getElementById("result").textContent = text;
-  } catch (ex) {
-    document.getElementById("result").textContent = ex.toString();
-  }
-}
-</script>
-
-</body>
-</html>

Modified: trunk/Source/WebCore/ChangeLog (134517 => 134518)


--- trunk/Source/WebCore/ChangeLog	2012-11-14 02:53:24 UTC (rev 134517)
+++ trunk/Source/WebCore/ChangeLog	2012-11-14 02:55:17 UTC (rev 134518)
@@ -1,3 +1,22 @@
+2012-11-13  Tab Atkins  <[email protected]>
+
+        CSS @charset parsing is too loose, doesn't match other browsers
+        https://bugs.webkit.org/show_bug.cgi?id=101527
+
+        Reviewed by Alexey Proskuryakov.
+
+        Per <https://www.w3.org/Bugs/Public/show_bug.cgi?id=19882#attach_1244>,
+        IE and FF have changed to be strict about @charset parsing,
+        as the CSS 2.1 spec requires.
+        Since @charset use is very uncommon anyway,
+        we should match the new behavior and the spec for platform consistency.
+
+        Test: fast/encoding/css-charset-evil/css-charset-evil.html
+
+        * loader/TextResourceDecoder.cpp:
+        (WebCore::bytesEqual):
+        (WebCore::TextResourceDecoder::checkForCSSCharset):
+
 2012-11-13  Kenichi Ishibashi  <[email protected]>
 
         [WebSocket] send() and close() should not throw an exception for an unpaired surrogate but use the replacement character

Modified: trunk/Source/WebCore/loader/TextResourceDecoder.cpp (134517 => 134518)


--- trunk/Source/WebCore/loader/TextResourceDecoder.cpp	2012-11-14 02:53:24 UTC (rev 134517)
+++ trunk/Source/WebCore/loader/TextResourceDecoder.cpp	2012-11-14 02:55:17 UTC (rev 134518)
@@ -64,6 +64,11 @@
     return p[0] == b0 && p[1] == b1 && p[2] == b2 && p[3] == b3 && p[4] == b4 && p[5] == b5 && p[6] == b6 && p[7] == b7;
 }
 
+static inline bool bytesEqual(const char* p, char b0, char b1, char b2, char b3, char b4, char b5, char b6, char b7, char b8, char b9)
+{
+    return p[0] == b0 && p[1] == b1 && p[2] == b2 && p[3] == b3 && p[4] == b4 && p[5] == b5 && p[6] == b6 && p[7] == b7 && p[8] == b8 && p[9] == b9;
+}
+
 // You might think we should put these find functions elsewhere, perhaps with the
 // similar functions that operate on UChar, but arguably only the decoder has
 // a reason to process strings of char rather than UChar.
@@ -465,37 +470,27 @@
 
     movedDataToBuffer = true;
 
-    if (m_buffer.size() <= 8) // strlen("@charset") == 8
+    if (m_buffer.size() <= 13) // strlen('@charset "x";') == 13
         return false;
 
     const char* dataStart = m_buffer.data();
     const char* dataEnd = dataStart + m_buffer.size();
 
-    if (bytesEqual(dataStart, '@', 'c', 'h', 'a', 'r', 's', 'e', 't')) {
-        dataStart += 8;
+    if (bytesEqual(dataStart, '@', 'c', 'h', 'a', 'r', 's', 'e', 't', ' ', '"')) {
+        dataStart += 10;
         const char* pos = dataStart;
-        if (!skipWhitespace(pos, dataEnd))
-            return false;
 
-        if (*pos == '"' || *pos == '\'') {
-            char quotationMark = *pos;
+        while (pos < dataEnd && *pos != '"')
             ++pos;
-            dataStart = pos;
+        if (pos == dataEnd)
+            return false;
+
+        int encodingNameLength = pos - dataStart;
         
-            while (pos < dataEnd && *pos != quotationMark)
-                ++pos;
-            if (pos == dataEnd)
-                return false;
+        ++pos;
 
-            int encodingNameLength = pos - dataStart;
-            
-            ++pos;
-            if (!skipWhitespace(pos, dataEnd))
-                return false;
-
-            if (*pos == ';')
-                setEncoding(findTextEncoding(dataStart, encodingNameLength), EncodingFromCSSCharset);
-        }
+        if (*pos == ';')
+            setEncoding(findTextEncoding(dataStart, encodingNameLength), EncodingFromCSSCharset);
     }
 
     m_checkedForCSSCharset = true;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to