2008-02-18 Alp Toker <alp@atoker.com>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Feb 2008 23:04:37 +0000 (23:04 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Feb 2008 23:04:37 +0000 (23:04 +0000)
        Reviewed by Mark Rowe.

        http://bugs.webkit.org/show_bug.cgi?id=17381
        [CURL] Regression: data URL parsing broken after DeprecatedString removal (Acid2)

        This patch resolves the regression for the GTK+ port.

        * platform/network/curl/ResourceHandleManager.cpp:
        (WebCore::parseDataUrl):

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

WebCore/ChangeLog
WebCore/platform/network/curl/ResourceHandleManager.cpp

index d49bf3c9a264528e3caac3c696d1b860b8fb62e7..ead22ac18d535d4bb2ce1e93c976565d9fefe5bc 100644 (file)
@@ -1,3 +1,15 @@
+2008-02-18  Alp Toker  <alp@atoker.com>
+
+        Reviewed by Mark Rowe.
+
+        http://bugs.webkit.org/show_bug.cgi?id=17381
+        [CURL] Regression: data URL parsing broken after DeprecatedString removal (Acid2)
+
+        This patch resolves the regression for the GTK+ port.
+
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::parseDataUrl):
+
 2008-02-18  Darin Adler  <darin@apple.com>
 
         Reviewed by Sam.
index 594cc194bfae7a394dbd4f043177789a7b62d8b6..b8fa696e42fc93b64ff617856d3adc14d89ad5c6 100644 (file)
@@ -463,6 +463,7 @@ bool ResourceHandleManager::startScheduledJobs()
     return started;
 }
 
+// FIXME: This function does not deal properly with text encodings.
 static void parseDataUrl(ResourceHandle* handle)
 {
     String data = handle->request().url().string();
@@ -486,14 +487,13 @@ static void parseDataUrl(ResourceHandle* handle)
 
     data = decodeURLEscapeSequences(data);
 
+    size_t outLength = 0;
+    char* outData = 0;
     if (base64 && !data.isEmpty()) {
         // Use the GLib Base64 if available, since WebCore's decoder isn't
         // general-purpose and fails on Acid3 test 97 (whitespace).
 #ifdef USE_GLIB_BASE64
-        gsize outLength;
-        guchar* out = g_base64_decode(data.latin1().data(), &outLength);
-        data = String(reinterpret_cast<char*>(out), outLength);
-        g_free(out);
+        outData = reinterpret_cast<char*>(g_base64_decode(data.utf8().data(), &outLength));
 #else
         Vector<char> out;
         if (base64Decode(data.latin1().data(), data.length(), out))
@@ -512,14 +512,23 @@ static void parseDataUrl(ResourceHandle* handle)
 
     response.setMimeType(extractMIMETypeFromMediaType(header));
     response.setTextEncodingName(extractCharsetFromMediaType(header));
-    response.setExpectedContentLength(data.length());
+    if (outData)
+        response.setExpectedContentLength(outLength);
+    else
+        response.setExpectedContentLength(data.length());
     response.setHTTPStatusCode(200);
 
     client->didReceiveResponse(handle, response);
 
-    if (!data.isEmpty())
+    if (outData)
+        client->didReceiveData(handle, outData, outLength, 0);
+    else
         client->didReceiveData(handle, data.latin1().data(), data.length(), 0);
 
+#ifdef USE_GLIB_BASE64
+    g_free(outData);
+#endif
+
     client->didFinishLoading(handle);
 }