Title: [228930] trunk/Source/WebKit
Revision
228930
Author
commit-qu...@webkit.org
Date
2018-02-22 12:42:54 -0800 (Thu, 22 Feb 2018)

Log Message

Fetch event release assert should take into account the fetch mode
https://bugs.webkit.org/show_bug.cgi?id=183047

Patch by Youenn Fablet <you...@apple.com> on 2018-02-22
Reviewed by Chris Dumez.

In case of navigation tasks, we should use the request URL and not the origin of the loading client.

* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::isValidFetch):
(WebKit::WebSWContextManagerConnection::startFetch):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (228929 => 228930)


--- trunk/Source/WebKit/ChangeLog	2018-02-22 19:50:57 UTC (rev 228929)
+++ trunk/Source/WebKit/ChangeLog	2018-02-22 20:42:54 UTC (rev 228930)
@@ -1,3 +1,16 @@
+2018-02-22  Youenn Fablet  <you...@apple.com>
+
+        Fetch event release assert should take into account the fetch mode
+        https://bugs.webkit.org/show_bug.cgi?id=183047
+
+        Reviewed by Chris Dumez.
+
+        In case of navigation tasks, we should use the request URL and not the origin of the loading client.
+
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::isValidFetch):
+        (WebKit::WebSWContextManagerConnection::startFetch):
+
 2018-02-22  Yousuke Kimoto  <yousuke.kim...@sony.com>
 
         [WinCairo] Fix compile errors in WebPageWin.cpp and WebProcessWin.cpp due to WebCore forwarding header paths

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (228929 => 228930)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2018-02-22 19:50:57 UTC (rev 228929)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2018-02-22 20:42:54 UTC (rev 228930)
@@ -180,6 +180,23 @@
         m_connectionToStorageProcess->send(Messages::WebSWServerToContextConnection::ScriptContextFailedToStart(jobDataIdentifier, serviceWorkerIdentifier, exceptionMessage), 0);
 }
 
+static inline bool isValidFetch(const ResourceRequest& request, const FetchOptions& options, const URL& serviceWorkerURL, const String& referrer)
+{
+    // For exotic service workers, do not enforce checks.
+    if (!serviceWorkerURL.protocolIsInHTTPFamily())
+        return true;
+
+    if (options.mode == FetchOptions::Mode::Navigate)
+        return protocolHostAndPortAreEqual(request.url(), serviceWorkerURL);
+
+    String origin = request.httpOrigin();
+    URL url { URL(), origin.isEmpty() ? referrer : origin };
+    if (!url.protocolIsInHTTPFamily())
+        return true;
+
+    return protocolHostAndPortAreEqual(url, serviceWorkerURL);
+}
+
 void WebSWContextManagerConnection::startFetch(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options, IPC::FormDataReference&& formData, String&& referrer)
 {
     auto* serviceWorkerThreadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(serviceWorkerIdentifier);
@@ -188,10 +205,7 @@
         return;
     }
 
-    String origin = request.httpOrigin();
-    URL url { URL(), origin.isEmpty() ? referrer : origin };
-    URL serviceWorkerURL = serviceWorkerThreadProxy->scriptURL();
-    RELEASE_ASSERT(!url.protocolIsInHTTPFamily() || !serviceWorkerURL.protocolIsInHTTPFamily() || protocolHostAndPortAreEqual(url, serviceWorkerURL));
+    RELEASE_ASSERT(isValidFetch(request, options, serviceWorkerThreadProxy->scriptURL(), referrer));
 
     auto client = WebServiceWorkerFetchTaskClient::create(m_connectionToStorageProcess.copyRef(), serviceWorkerIdentifier, serverConnectionIdentifier, fetchIdentifier);
     std::optional<ServiceWorkerClientIdentifier> clientId;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to