Changeset 253544 in webkit


Ignore:
Timestamp:
Dec 16, 2019 3:04:41 AM (4 years ago)
Author:
youenn@apple.com
Message:

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.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r253540 r253544  
     12019-12-16  youenn fablet  <youenn@apple.com>
     2
     3        SecurityOrigin should be unique for null blob URLs that have been unregistered
     4        https://bugs.webkit.org/show_bug.cgi?id=205169
     5
     6        Reviewed by Darin Adler.
     7
     8        * http/tests/security/blob-null-url-location-origin-expected.txt: Added.
     9        * http/tests/security/blob-null-url-location-origin.html: Added.
     10        * platform/win/TestExpectations: Skipping test as timing out in windows.
     11
    1122019-12-15  Emilio Cobos Álvarez  <emilio@crisal.io>
    213
  • trunk/LayoutTests/platform/win/TestExpectations

    r253486 r253544  
    744744http/tests/security/contentSecurityPolicy/same-origin-plugin-document-blocked-in-child-window-report.php [ Skip ]
    745745http/tests/security/contentSecurityPolicy/same-origin-plugin-document-with-csp-blocked-in-child-window.html [ Skip ]
     746
     747http/tests/security/blob-null-url-location-origin.html [ Skip ]
    746748
    747749################################################################################
  • trunk/Source/WebCore/ChangeLog

    r253541 r253544  
     12019-12-16  youenn fablet  <youenn@apple.com>
     2
     3        SecurityOrigin should be unique for null blob URLs that have been unregistered
     4        https://bugs.webkit.org/show_bug.cgi?id=205169
     5
     6        Reviewed by Darin Adler.
     7
     8        In case we cannot retrieve a cached origin for a null origin, just create a unique one.
     9        This is better than having an origin with an empty host and empty scheme.
     10
     11        Test: http/tests/security/blob-null-url-location-origin.html
     12
     13        * fileapi/ThreadableBlobRegistry.cpp:
     14        (WebCore::ThreadableBlobRegistry::unregisterBlobURL):
     15        (WebCore::ThreadableBlobRegistry::getCachedOrigin):
     16
    1172019-12-15  Emilio Cobos Álvarez  <emilio@crisal.io>
    218
  • trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp

    r250061 r253544  
    9090}
    9191
     92static inline bool isBlobURLContainsNullOrigin(const URL& url)
     93{
     94    ASSERT(url.protocolIsBlob());
     95    return BlobURL::getOrigin(url) == "null";
     96}
     97
    9298void ThreadableBlobRegistry::registerBlobURL(SecurityOrigin* origin, const URL& url, const URL& srcURL)
    9399{
    94100    // 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.
    95     if (origin && BlobURL::getOrigin(url) == "null")
     101    if (origin && isBlobURLContainsNullOrigin(url))
    96102        originMap()->add(url.string(), origin);
    97103
     
    146152void ThreadableBlobRegistry::unregisterBlobURL(const URL& url)
    147153{
    148     if (BlobURL::getOrigin(url) == "null")
     154    if (isBlobURLContainsNullOrigin(url))
    149155        originMap()->remove(url.string());
    150156
     
    160166RefPtr<SecurityOrigin> ThreadableBlobRegistry::getCachedOrigin(const URL& url)
    161167{
    162     return originMap()->get(url.string());
     168    if (auto cachedOrigin = originMap()->get(url.string()))
     169        return cachedOrigin;
     170
     171    if (!url.protocolIsBlob() || !isBlobURLContainsNullOrigin(url))
     172        return nullptr;
     173
     174    // If we do not have a cached origin for null blob URLs, we use a unique origin.
     175    return SecurityOrigin::createUnique();
    163176}
    164177
Note: See TracChangeset for help on using the changeset viewer.