Title: [184086] releases/WebKitGTK/webkit-2.8
Revision
184086
Author
[email protected]
Date
2015-05-11 06:04:15 -0700 (Mon, 11 May 2015)

Log Message

Merge r182943 - [SOUP] Redirect to non HTTP destination is broken
https://bugs.webkit.org/show_bug.cgi?id=143866

Reviewed by Sergio Villar Senin.

Source/WebCore:

This is because we are passing true unconditionally as
isHTTPFamilyRequest parameter of
createSoupRequestAndMessageForHandle in continueAfterWillSendRequest.
We don't actually need to pass isHTTPFamilyRequest parameter to
createSoupRequestAndMessageForHandle, since it can simply check
that from the given request.

Covered by unit tets and also cache/disk-cache/disk-cache-redirect-to-data.html.

* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::continueAfterWillSendRequest):
(WebCore::createSoupRequestAndMessageForHandle):
(WebCore::ResourceHandle::start):

Tools:

Add a unit test to check that redirect to a data URI works.

* TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp:
(testRedirectToDataURI):
(serverCallback):
(beforeAll):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog (184085 => 184086)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog	2015-05-11 13:01:19 UTC (rev 184085)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog	2015-05-11 13:04:15 UTC (rev 184086)
@@ -1,3 +1,24 @@
+2015-04-17  Carlos Garcia Campos  <[email protected]>
+
+        [SOUP] Redirect to non HTTP destination is broken
+        https://bugs.webkit.org/show_bug.cgi?id=143866
+
+        Reviewed by Sergio Villar Senin.
+
+        This is because we are passing true unconditionally as
+        isHTTPFamilyRequest parameter of
+        createSoupRequestAndMessageForHandle in continueAfterWillSendRequest.
+        We don't actually need to pass isHTTPFamilyRequest parameter to
+        createSoupRequestAndMessageForHandle, since it can simply check
+        that from the given request.
+
+        Covered by unit tets and also cache/disk-cache/disk-cache-redirect-to-data.html.
+
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::continueAfterWillSendRequest):
+        (WebCore::createSoupRequestAndMessageForHandle):
+        (WebCore::ResourceHandle::start):
+
 2015-04-16  Brady Eidson  <[email protected]>
 
         Media element can manipulate DOM during Document destruction.

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (184085 => 184086)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2015-05-11 13:01:19 UTC (rev 184085)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2015-05-11 13:04:15 UTC (rev 184086)
@@ -227,7 +227,7 @@
     HashSet<String> m_certificates;
 };
 
-static bool createSoupRequestAndMessageForHandle(ResourceHandle*, const ResourceRequest&, bool isHTTPFamilyRequest);
+static bool createSoupRequestAndMessageForHandle(ResourceHandle*, const ResourceRequest&);
 static void cleanupSoupRequestOperation(ResourceHandle*, bool isDestroying = false);
 static void sendRequestCallback(GObject*, GAsyncResult*, gpointer);
 static void readCallback(GObject*, GAsyncResult*, gpointer);
@@ -468,7 +468,7 @@
     if (protocolHostAndPortAreEqual(newRequest.url(), d->m_response.url()))
         applyAuthenticationToRequest(handle, newRequest, true);
 
-    if (!createSoupRequestAndMessageForHandle(handle, newRequest, true)) {
+    if (!createSoupRequestAndMessageForHandle(handle, newRequest)) {
         d->client()->cannotShowURL(handle);
         return;
     }
@@ -967,7 +967,7 @@
     return true;
 }
 
-static bool createSoupRequestAndMessageForHandle(ResourceHandle* handle, const ResourceRequest& request, bool isHTTPFamilyRequest)
+static bool createSoupRequestAndMessageForHandle(ResourceHandle* handle, const ResourceRequest& request)
 {
     ResourceHandleInternal* d = handle->getInternal();
 
@@ -983,7 +983,7 @@
     }
 
     // SoupMessages are only applicable to HTTP-family requests.
-    if (isHTTPFamilyRequest && !createSoupMessageForHandleAndRequest(handle, request)) {
+    if (request.url().protocolIsInHTTPFamily() && !createSoupMessageForHandleAndRequest(handle, request)) {
         d->m_soupRequest.clear();
         return false;
     }
@@ -1007,15 +1007,14 @@
 
     // Only allow the POST and GET methods for non-HTTP requests.
     const ResourceRequest& request = firstRequest();
-    bool isHTTPFamilyRequest = request.url().protocolIsInHTTPFamily();
-    if (!isHTTPFamilyRequest && request.httpMethod() != "GET" && request.httpMethod() != "POST") {
+    if (!request.url().protocolIsInHTTPFamily() && request.httpMethod() != "GET" && request.httpMethod() != "POST") {
         this->scheduleFailure(InvalidURLFailure); // Error must not be reported immediately
         return true;
     }
 
     applyAuthenticationToRequest(this, firstRequest(), false);
 
-    if (!createSoupRequestAndMessageForHandle(this, request, isHTTPFamilyRequest)) {
+    if (!createSoupRequestAndMessageForHandle(this, request)) {
         this->scheduleFailure(InvalidURLFailure); // Error must not be reported immediately
         return true;
     }

Modified: releases/WebKitGTK/webkit-2.8/Tools/ChangeLog (184085 => 184086)


--- releases/WebKitGTK/webkit-2.8/Tools/ChangeLog	2015-05-11 13:01:19 UTC (rev 184085)
+++ releases/WebKitGTK/webkit-2.8/Tools/ChangeLog	2015-05-11 13:04:15 UTC (rev 184086)
@@ -1,3 +1,17 @@
+2015-04-17  Carlos Garcia Campos  <[email protected]>
+
+        [SOUP] Redirect to non HTTP destination is broken
+        https://bugs.webkit.org/show_bug.cgi?id=143866
+
+        Reviewed by Sergio Villar Senin.
+
+        Add a unit test to check that redirect to a data URI works.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp:
+        (testRedirectToDataURI):
+        (serverCallback):
+        (beforeAll):
+
 2015-04-08  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Crash in DOMObjectCache when a wrapped object owned by the cache is unreffed by the user

Modified: releases/WebKitGTK/webkit-2.8/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp (184085 => 184086)


--- releases/WebKitGTK/webkit-2.8/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp	2015-05-11 13:01:19 UTC (rev 184085)
+++ releases/WebKitGTK/webkit-2.8/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp	2015-05-11 13:04:15 UTC (rev 184086)
@@ -425,6 +425,18 @@
     g_assert_cmpstr(soup_message_headers_get_one(headers, "Foo"), ==, "bar");
 }
 
+static void testRedirectToDataURI(WebViewTest* test, gconstpointer)
+{
+    test->loadURI(kServer->getURIForPath("/redirect-to-data").data());
+    test->waitUntilLoadFinished();
+
+    static const char* expectedData = "data-uri";
+    size_t mainResourceDataSize = 0;
+    const char* mainResourceData = test->mainResourceData(mainResourceDataSize);
+    g_assert_cmpint(mainResourceDataSize, ==, strlen(expectedData));
+    g_assert(!strncmp(mainResourceData, expectedData, mainResourceDataSize));
+}
+
 static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
 {
     static const char* responseString = "<html><body>Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
@@ -465,6 +477,9 @@
     } else if (g_str_equal(path, "/headers")) {
         soup_message_headers_append(message->response_headers, "Foo", "bar");
         soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString));
+    } else if (g_str_equal(path, "/redirect-to-data")) {
+        soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
+        soup_message_headers_append(message->response_headers, "Location", "data:text/plain;charset=utf-8,data-uri");
     } else
         soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
 
@@ -502,6 +517,7 @@
     WebPageURITest::add("WebKitWebPage", "get-uri", testWebPageURI);
     WebViewTest::add("WebKitURIRequest", "http-headers", testURIRequestHTTPHeaders);
     WebViewTest::add("WebKitURIResponse", "http-headers", testURIResponseHTTPHeaders);
+    WebViewTest::add("WebKitWebPage", "redirect-to-data-uri", testRedirectToDataURI);
 }
 
 void afterAll()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to