Title: [106253] trunk/Source
Revision
106253
Author
msab...@apple.com
Date
2012-01-30 10:10:43 -0800 (Mon, 30 Jan 2012)

Log Message

WebCore decodeEscapeSequences unnecessarily converts 8 bit strings to 16 bit when decoding.
https://bugs.webkit.org/show_bug.cgi?id=76648

Reviewed by Geoffrey Garen.

Source/_javascript_Core: 

Added a new overloaded append member that takes a String& argument, an offest
and a length to do direct sub string appending to a StringBuilder.

* wtf/text/StringBuilder.h:
(WTF::StringBuilder::append):

Source/WebCore: 

Using new overloaded append(String&, offset, length)  member to build result string.
The new member properly handles 8/16 bit-ness of strings.

Functionality not changed, therefore no new tests.

* platform/text/DecodeEscapeSequences.h:
(WebCore::decodeEscapeSequences):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (106252 => 106253)


--- trunk/Source/_javascript_Core/ChangeLog	2012-01-30 17:53:53 UTC (rev 106252)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-01-30 18:10:43 UTC (rev 106253)
@@ -1,3 +1,16 @@
+2012-01-30  Michael Saboff  <msab...@apple.com>
+
+        WebCore decodeEscapeSequences unnecessarily converts 8 bit strings to 16 bit when decoding.
+        https://bugs.webkit.org/show_bug.cgi?id=76648
+
+        Reviewed by Geoffrey Garen.
+
+        Added a new overloaded append member that takes a String& argument, an offest
+        and a length to do direct sub string appending to a StringBuilder.
+
+        * wtf/text/StringBuilder.h:
+        (WTF::StringBuilder::append):
+
 2012-01-29  Zoltan Herczeg  <zherc...@webkit.org>
 
         Custom written CSS lexer

Modified: trunk/Source/_javascript_Core/wtf/text/StringBuilder.h (106252 => 106253)


--- trunk/Source/_javascript_Core/wtf/text/StringBuilder.h	2012-01-30 17:53:53 UTC (rev 106252)
+++ trunk/Source/_javascript_Core/wtf/text/StringBuilder.h	2012-01-30 18:10:43 UTC (rev 106253)
@@ -86,6 +86,20 @@
         append(other.characters(), other.m_length);
     }
 
+    void append(const String& string, unsigned offset, unsigned length)
+    {
+        if (!string.length())
+            return;
+
+        if ((offset + length) > string.length())
+            return;
+
+        if (string.is8Bit())
+            append(string.characters8() + offset, length);
+        else
+            append(string.characters16() + offset, length);
+    }
+
     void append(const char* characters)
     {
         if (characters)

Modified: trunk/Source/WebCore/ChangeLog (106252 => 106253)


--- trunk/Source/WebCore/ChangeLog	2012-01-30 17:53:53 UTC (rev 106252)
+++ trunk/Source/WebCore/ChangeLog	2012-01-30 18:10:43 UTC (rev 106253)
@@ -1,3 +1,18 @@
+2012-01-30  Michael Saboff  <msab...@apple.com>
+
+        WebCore decodeEscapeSequences unnecessarily converts 8 bit strings to 16 bit when decoding.
+        https://bugs.webkit.org/show_bug.cgi?id=76648
+
+        Reviewed by Geoffrey Garen.
+
+        Using new overloaded append(String&, offset, length)  member to build result string.
+        The new member properly handles 8/16 bit-ness of strings.
+
+        Functionality not changed, therefore no new tests.
+
+        * platform/text/DecodeEscapeSequences.h:
+        (WebCore::decodeEscapeSequences):
+
 2012-01-30  Pavel Feldman  <pfeld...@google.com>
 
         Not reviewed: follow up to r105625, use proper event categoty in inspector frontend.

Modified: trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h (106252 => 106253)


--- trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h	2012-01-30 17:53:53 UTC (rev 106252)
+++ trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h	2012-01-30 18:10:43 UTC (rev 106253)
@@ -139,11 +139,11 @@
         if (decoded.isEmpty())
             continue;
 
-        result.append(string.characters() + decodedPosition, encodedRunPosition - decodedPosition);
+        result.append(string, decodedPosition, encodedRunPosition - decodedPosition);
         result.append(decoded);
         decodedPosition = encodedRunEnd;
     }
-    result.append(string.characters() + decodedPosition, length - decodedPosition);
+    result.append(string, decodedPosition, length - decodedPosition);
     return result.toString();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to