Title: [256591] releases/WebKitGTK/webkit-2.26
Revision
256591
Author
[email protected]
Date
2020-02-14 01:40:01 -0800 (Fri, 14 Feb 2020)

Log Message

Merge r253544 - SecurityOrigin should be unique for null blob URLs that have been unregistered
https://bugs.webkit.org/show_bug.cgi?id=205169

Reviewed by Darin Adler.

Source/WebCore:

In case we cannot retrieve a cached origin for a null origin, just create a unique one.
This is better than having an origin with an empty host and empty scheme.

Test: http/tests/security/blob-null-url-location-origin.html

* fileapi/ThreadableBlobRegistry.cpp:
(WebCore::ThreadableBlobRegistry::unregisterBlobURL):
(WebCore::ThreadableBlobRegistry::getCachedOrigin):

LayoutTests:

* http/tests/security/blob-null-url-location-origin-expected.txt: Added.
* http/tests/security/blob-null-url-location-origin.html: Added.
* platform/win/TestExpectations: Skipping test as timing out in windows.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.26/LayoutTests/ChangeLog (256590 => 256591)


--- releases/WebKitGTK/webkit-2.26/LayoutTests/ChangeLog	2020-02-14 09:39:55 UTC (rev 256590)
+++ releases/WebKitGTK/webkit-2.26/LayoutTests/ChangeLog	2020-02-14 09:40:01 UTC (rev 256591)
@@ -1,3 +1,14 @@
+2019-12-16  youenn fablet  <[email protected]>
+
+        SecurityOrigin should be unique for null blob URLs that have been unregistered
+        https://bugs.webkit.org/show_bug.cgi?id=205169
+
+        Reviewed by Darin Adler.
+
+        * http/tests/security/blob-null-url-location-origin-expected.txt: Added.
+        * http/tests/security/blob-null-url-location-origin.html: Added.
+        * platform/win/TestExpectations: Skipping test as timing out in windows.
+
 2020-01-28  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Should use light theme unless website declares support for dark themes in color-schemes property

Added: releases/WebKitGTK/webkit-2.26/LayoutTests/http/tests/security/blob-null-url-location-origin-expected.txt (0 => 256591)


--- releases/WebKitGTK/webkit-2.26/LayoutTests/http/tests/security/blob-null-url-location-origin-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.26/LayoutTests/http/tests/security/blob-null-url-location-origin-expected.txt	2020-02-14 09:40:01 UTC (rev 256591)
@@ -0,0 +1,5 @@
+CONSOLE MESSAGE: line 1: data URL frame loaded
+CONSOLE MESSAGE: line 1: blob popup opened
+CONSOLE MESSAGE: line 1: blob popup loadednull
+CONSOLE MESSAGE: line 1: blob popup message posted
+PASS

Added: releases/WebKitGTK/webkit-2.26/LayoutTests/http/tests/security/blob-null-url-location-origin.html (0 => 256591)


--- releases/WebKitGTK/webkit-2.26/LayoutTests/http/tests/security/blob-null-url-location-origin.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.26/LayoutTests/http/tests/security/blob-null-url-location-origin.html	2020-02-14 09:40:01 UTC (rev 256591)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<body>
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+    testRunner.setCanOpenWindows();
+}
+
+let count = 0;
+_onmessage_ = (event) => {
+    ++count;
+    if (event.data !== "null") {
+        document.body.innerHTML = "FAIL, got " + event.data + " with count " + count;
+        if (window.testRunner)
+            testRunner.notifyDone();
+        window.clearTimeout(timer);
+        count = 3;
+        return;
+    }
+    if (count === 2) {
+        document.body.innerHTML = "PASS";
+        if (window.testRunner)
+            testRunner.notifyDone();
+        window.clearTimeout(timer);
+    }
+};
+
+const timer = setTimeout(() => {
+    document.body.innerHTML = "TIMEOUT";
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, 10000);
+</script>
+<iframe src="" URL frame loaded'); const blob = new Blob(['<'+ 'script>console.log(\'blob popup loaded\' + location.origin); _onload_ = () => window.opener.postMessage(location.origin, \'*\'); console.log(\'blob popup message posted\'); _onmessage_ = () => window.opener.postMessage(location.origin, \'*\'); <' + '/script>'], {type: 'text/html'}); const blobURL = URL.createObjectURL(blob); const popup = window.open(blobURL); _onmessage_ = (event) => { popup.postMessage('check', '*'); parent.postMessage(event.data, '*'); URL.revokeObjectURL(blobURL); _onmessage_ = (event) => { parent.postMessage(event.data, '*'); popup.close(); }; }; console.log('blob popup opened'); </script>"></iframe>
+</body>

Modified: releases/WebKitGTK/webkit-2.26/LayoutTests/platform/win/TestExpectations (256590 => 256591)


--- releases/WebKitGTK/webkit-2.26/LayoutTests/platform/win/TestExpectations	2020-02-14 09:39:55 UTC (rev 256590)
+++ releases/WebKitGTK/webkit-2.26/LayoutTests/platform/win/TestExpectations	2020-02-14 09:40:01 UTC (rev 256591)
@@ -735,6 +735,8 @@
 http/tests/security/contentSecurityPolicy/same-origin-plugin-document-blocked-in-child-window-report.php [ Skip ]
 http/tests/security/contentSecurityPolicy/same-origin-plugin-document-with-csp-blocked-in-child-window.html [ Skip ]
 
+http/tests/security/blob-null-url-location-origin.html [ Skip ]
+
 ################################################################################
 ############################   End Plugin Failures   ###########################
 ################################################################################

Modified: releases/WebKitGTK/webkit-2.26/Source/WebCore/ChangeLog (256590 => 256591)


--- releases/WebKitGTK/webkit-2.26/Source/WebCore/ChangeLog	2020-02-14 09:39:55 UTC (rev 256590)
+++ releases/WebKitGTK/webkit-2.26/Source/WebCore/ChangeLog	2020-02-14 09:40:01 UTC (rev 256591)
@@ -1,3 +1,19 @@
+2019-12-16  youenn fablet  <[email protected]>
+
+        SecurityOrigin should be unique for null blob URLs that have been unregistered
+        https://bugs.webkit.org/show_bug.cgi?id=205169
+
+        Reviewed by Darin Adler.
+
+        In case we cannot retrieve a cached origin for a null origin, just create a unique one.
+        This is better than having an origin with an empty host and empty scheme.
+
+        Test: http/tests/security/blob-null-url-location-origin.html
+
+        * fileapi/ThreadableBlobRegistry.cpp:
+        (WebCore::ThreadableBlobRegistry::unregisterBlobURL):
+        (WebCore::ThreadableBlobRegistry::getCachedOrigin):
+
 2020-02-05  Michael Catanzaro  <[email protected]>
 
         [GTK] Cannot perform most local loads with sandbox enabled

Modified: releases/WebKitGTK/webkit-2.26/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp (256590 => 256591)


--- releases/WebKitGTK/webkit-2.26/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp	2020-02-14 09:39:55 UTC (rev 256590)
+++ releases/WebKitGTK/webkit-2.26/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp	2020-02-14 09:40:01 UTC (rev 256591)
@@ -89,10 +89,16 @@
     });
 }
 
+static inline bool isBlobURLContainsNullOrigin(const URL& url)
+{
+    ASSERT(url.protocolIsBlob());
+    return BlobURL::getOrigin(url) == "null";
+}
+
 void ThreadableBlobRegistry::registerBlobURL(PAL::SessionID sessionID, SecurityOrigin* origin, const URL& url, const URL& srcURL)
 {
     // If the blob URL contains null origin, as in the context with unique security origin or file URL, save the mapping between url and origin so that the origin can be retrived when doing security origin check.
-    if (origin && BlobURL::getOrigin(url) == "null")
+    if (origin && isBlobURLContainsNullOrigin(url))
         originMap()->add(url.string(), origin);
 
     if (isMainThread()) {
@@ -145,7 +151,7 @@
 
 void ThreadableBlobRegistry::unregisterBlobURL(PAL::SessionID sessionID, const URL& url)
 {
-    if (BlobURL::getOrigin(url) == "null")
+    if (isBlobURLContainsNullOrigin(url))
         originMap()->remove(url.string());
 
     if (isMainThread()) {
@@ -159,7 +165,14 @@
 
 RefPtr<SecurityOrigin> ThreadableBlobRegistry::getCachedOrigin(const URL& url)
 {
-    return originMap()->get(url.string());
+    if (auto cachedOrigin = originMap()->get(url.string()))
+        return cachedOrigin;
+
+    if (!url.protocolIsBlob() || !isBlobURLContainsNullOrigin(url))
+        return nullptr;
+
+    // If we do not have a cached origin for null blob URLs, we use a unique origin.
+    return SecurityOrigin::createUnique();
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to