Title: [131954] trunk/Source/WebCore
Revision
131954
Author
[email protected]
Date
2012-10-19 16:19:40 -0700 (Fri, 19 Oct 2012)

Log Message

String(CFStringRef) should try to converting to an 8 bit string before converting to  16 bit string
https://bugs.webkit.org/show_bug.cgi?id=99794

Reviewed by Filip Pizlo.

Try getting a Latin1 byte string before getting a UTF16 (UChar*) string.

No new test, added 8 bit path.

* platform/text/cf/StringCF.cpp:
(WTF::String::String):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (131953 => 131954)


--- trunk/Source/WebCore/ChangeLog	2012-10-19 23:13:08 UTC (rev 131953)
+++ trunk/Source/WebCore/ChangeLog	2012-10-19 23:19:40 UTC (rev 131954)
@@ -1,3 +1,17 @@
+2012-10-19  Michael Saboff  <[email protected]>
+
+        String(CFStringRef) should try to converting to an 8 bit string before converting to  16 bit string
+        https://bugs.webkit.org/show_bug.cgi?id=99794
+
+        Reviewed by Filip Pizlo.
+
+        Try getting a Latin1 byte string before getting a UTF16 (UChar*) string.
+
+        No new test, added 8 bit path.
+
+        * platform/text/cf/StringCF.cpp:
+        (WTF::String::String):
+
 2012-10-19  Dima Gorbik  <[email protected]>
 
         Page should be removed from the cache right after restore was called.

Modified: trunk/Source/WebCore/platform/text/cf/StringCF.cpp (131953 => 131954)


--- trunk/Source/WebCore/platform/text/cf/StringCF.cpp	2012-10-19 23:13:08 UTC (rev 131953)
+++ trunk/Source/WebCore/platform/text/cf/StringCF.cpp	2012-10-19 23:19:40 UTC (rev 131954)
@@ -37,6 +37,14 @@
     if (size == 0)
         m_impl = StringImpl::empty();
     else {
+        Vector<LChar, 1024> lcharBuffer(size);
+        CFIndex usedBufLen;
+        CFIndex convertedsize = CFStringGetBytes(str, CFRangeMake(0, size), kCFStringEncodingISOLatin1, 0, false, lcharBuffer.data(), size, &usedBufLen);
+        if ((convertedsize == size) && (usedBufLen == size)) {
+            m_impl = StringImpl::create(lcharBuffer.data(), size);
+            return;
+        }
+
         Vector<UChar, 1024> buffer(size);
         CFStringGetCharacters(str, CFRangeMake(0, size), (UniChar*)buffer.data());
         m_impl = StringImpl::create(buffer.data(), size);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to