Title: [114876] trunk
Revision
114876
Author
commit-qu...@webkit.org
Date
2012-04-23 00:47:39 -0700 (Mon, 23 Apr 2012)

Log Message

Source/WebCore: Incorrect handling of CSS escape sequences that encode surrogates
https://bugs.webkit.org/show_bug.cgi?id=76152

Patch by Szilard Ledan <szle...@inf.u-szeged.hu> on 2012-04-23
Reviewed by Kent Tamura.

Test: fast/css/parsing-css-surrogate-pairs.html

* css/CSSParser.cpp:
(WebCore::CSSParser::parseEscape):

LayoutTests: Added a test for css surrogate pairs parser
https://bugs.webkit.org/show_bug.cgi?id=76152

Patch by Szilard Ledan <szle...@inf.u-szeged.hu> on 2012-04-23
Reviewed by Kent Tamura.

* fast/css/parsing-css-surrogate-pairs-expected.txt: Added.
* fast/css/parsing-css-surrogate-pairs.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (114875 => 114876)


--- trunk/LayoutTests/ChangeLog	2012-04-23 07:10:29 UTC (rev 114875)
+++ trunk/LayoutTests/ChangeLog	2012-04-23 07:47:39 UTC (rev 114876)
@@ -1,3 +1,13 @@
+2012-04-23  Szilard Ledan  <szle...@inf.u-szeged.hu>
+
+        Added a test for css surrogate pairs parser
+        https://bugs.webkit.org/show_bug.cgi?id=76152
+
+        Reviewed by Kent Tamura.
+
+        * fast/css/parsing-css-surrogate-pairs-expected.txt: Added.
+        * fast/css/parsing-css-surrogate-pairs.html: Added.
+
 2012-04-22  Csaba Osztrogonác  <o...@webkit.org>
 
         Add Notification constructor

Added: trunk/LayoutTests/fast/css/parsing-css-surrogate-pairs-expected.txt (0 => 114876)


--- trunk/LayoutTests/fast/css/parsing-css-surrogate-pairs-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/parsing-css-surrogate-pairs-expected.txt	2012-04-23 07:47:39 UTC (rev 114876)
@@ -0,0 +1,37 @@
+Test parsing of CSS surrogate pairs.
+
+SUCCESS
+
+Rules from the stylesheet:
+
+#a61_a { color: red; }
+#b61_a { color: green; }
+#a65530_ { color: red; }
+#b65530_ { color: green; }
+#a65532_ { color: red; }
+#b65532_ { color: green; }
+#a65533_� { color: red; }
+#b65533_� { color: green; }
+#a65536_𐀀 { color: red; }
+#b65536_𐀀 { color: green; }
+#a119558_𝌆 { color: red; }
+#b119558_𝌆 { color: green; }
+Expected result:
+
+#a61_a { color: red; }
+#b61_a { color: green; }
+#a65530_ { color: red; }
+#b65530_ { color: green; }
+#a65532_ { color: red; }
+#b65532_ { color: green; }
+#a65533_� { color: red; }
+#b65533_� { color: green; }
+#a65536_𐀀 { color: red; }
+#b65536_𐀀 { color: green; }
+#a119558_𝌆 { color: red; }
+#b119558_𝌆 { color: green; }
+
+
+
+
+

Added: trunk/LayoutTests/fast/css/parsing-css-surrogate-pairs.html (0 => 114876)


--- trunk/LayoutTests/fast/css/parsing-css-surrogate-pairs.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/parsing-css-surrogate-pairs.html	2012-04-23 07:47:39 UTC (rev 114876)
@@ -0,0 +1,89 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+<style>
+/*
+  === Warning ===
+
+  This file intentionally contains scpecial characters which
+  cannot be displayed by some text editors. Please
+  carefully edit the file.
+*/
+
+/* basic */
+#a61_a { color: red; }
+#b61_\61 { color: green; }
+
+#a65530_ { color: red; }
+#b65530_\fffa { color: green; }
+
+#a65532_ { color: red; }
+#b65532_\fffc { color: green; }
+
+#a65533_� { color: red; }
+#b65533_\fffd { color: green; }
+
+/* above the 0xffff */
+#a65536_𐀀 { color: red; }
+#b65536_\10000 { color: green; }
+
+#a119558_𝌆 { color: red; }
+#b119558_\01d306 { color: green; }
+</style>
+
+<script>
+
+function runTest()
+{
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    var rules = document.styleSheets[0].cssRules;
+    var text = "";
+    for (var i = 0; i < rules.length; i++) {
+        text += rules.item(i).cssText;
+        text += "\n";
+    }
+
+    document.getElementById("result").appendChild(document.createTextNode(text));
+
+    if (document.getElementById("result").firstChild.data ="" document.getElementById("expected").firstChild.data)
+        document.getElementById("message").firstChild.data = ""
+    else
+        document.getElementById("message").firstChild.data = ""
+}
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+
+<p>Test parsing of CSS surrogate pairs.</p>
+
+<p id="message">TEST DID NOT COMPLETE</p>
+
+<p>Rules from the stylesheet:</p>
+
+<pre id="result"></pre>
+
+<p>Expected result:</p>
+
+<pre id="expected">#a61_a { color: red; }
+#b61_a { color: green; }
+#a65530_ { color: red; }
+#b65530_ { color: green; }
+#a65532_ { color: red; }
+#b65532_ { color: green; }
+#a65533_� { color: red; }
+#b65533_� { color: green; }
+#a65536_𐀀 { color: red; }
+#b65536_𐀀 { color: green; }
+#a119558_𝌆 { color: red; }
+#b119558_𝌆 { color: green; }
+<script>
+
+</script>
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (114875 => 114876)


--- trunk/Source/WebCore/ChangeLog	2012-04-23 07:10:29 UTC (rev 114875)
+++ trunk/Source/WebCore/ChangeLog	2012-04-23 07:47:39 UTC (rev 114876)
@@ -1,3 +1,15 @@
+2012-04-23  Szilard Ledan  <szle...@inf.u-szeged.hu>
+
+        Incorrect handling of CSS escape sequences that encode surrogates
+        https://bugs.webkit.org/show_bug.cgi?id=76152
+
+        Reviewed by Kent Tamura.
+
+        Test: fast/css/parsing-css-surrogate-pairs.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseEscape):
+
 2012-04-22  Yury Semikhatsky  <yu...@chromium.org>
 
         Web Inspector: make populateChildren methods private in heap profiler front-end

Modified: trunk/Source/WebCore/css/CSSParser.cpp (114875 => 114876)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-04-23 07:10:29 UTC (rev 114875)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-04-23 07:47:39 UTC (rev 114876)
@@ -7969,14 +7969,20 @@
             unicode = (unicode << 4) + toASCIIHexValue(*m_currentCharacter++);
         } while (--length && isASCIIHexDigit(*m_currentCharacter));
 
-        // Characters above 0xffff are not handled.
-        if (unicode > 0xffff)
+        // Characters above 0x10ffff are not handled.
+        if (unicode > 0x10ffff)
             unicode = 0xfffd;
 
         // Optional space after the escape sequence.
         if (isHTMLSpace(*m_currentCharacter))
             ++m_currentCharacter;
-        *result = unicode;
+
+        // Replace unicode with a surrogate pairs when it is bigger than 0xffff
+        if (U16_LENGTH(unicode) == 2) {
+            *result++ = U16_LEAD(unicode);
+            *result = U16_TRAIL(unicode);
+        } else
+            *result = unicode;
     } else
         *result = *m_currentCharacter++;
     ++result;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to