Reviewed by Darin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Feb 2006 10:34:55 +0000 (10:34 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Feb 2006 10:34:55 +0000 (10:34 +0000)
        - improve fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=5163
        RealPlayer.GetTitle() Crashes Safari/Dashboard

        * bindings/c/c_utility.cpp: (KJS::Bindings::convertUTF8ToUTF16):
        Use kCFStringEncodingISOLatin1 rather than kCFStringEncodingWindowsLatin1,
        because the latter encoding has holes, and conversion can still fail.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@12752 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/bindings/c/c_utility.cpp

index 9d60091d714be02e8c0f2a0c46454fc96d410913..4aa4c623bff517c3ca7e4b1459f981ecdf59da73 100644 (file)
@@ -1,3 +1,14 @@
+2006-02-11  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Darin.
+
+        - improve fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=5163
+        RealPlayer.GetTitle() Crashes Safari/Dashboard
+
+        * bindings/c/c_utility.cpp: (KJS::Bindings::convertUTF8ToUTF16):
+        Use kCFStringEncodingISOLatin1 rather than kCFStringEncodingWindowsLatin1, 
+        because the latter encoding has holes, and conversion can still fail.
+
 2006-02-10  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Darin.
index f185c3b4237cbbfb6c0b8d48ce8fef82770ebbd7..75030c45eb16f1e7a956650968cf9a678ce08cc1 100644 (file)
@@ -53,9 +53,11 @@ void convertUTF8ToUTF16(const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16
     
     // Some plugins return invalid UTF-8 in NPVariantType_String, see <http://bugzilla.opendarwin.org/show_bug.cgi?id=5163>
     if (!stringRef)
-        stringRef = CFStringCreateWithBytes(NULL, (const UInt8*)UTF8Chars, (CFIndex)UTF8Length, kCFStringEncodingWindowsLatin1, false);
+        stringRef = CFStringCreateWithBytes(NULL, (const UInt8*)UTF8Chars, (CFIndex)UTF8Length, kCFStringEncodingISOLatin1, false);
 
-    assert(stringRef); // there is no "bad data" for kCFStringEncodingWindowsLatin1
+    // There is no "bad data" for kCFStringEncodingISOLatin1. It is unlikely that the plugin was really sending text in this encoding,
+    // but it should have used UTF-8, and now we are simply avoiding a crash.
+    assert(stringRef);
 
     *UTF16Length = (unsigned int)CFStringGetLength(stringRef);
     *UTF16Chars = (NPUTF16 *)malloc(sizeof(NPUTF16) * (*UTF16Length));