⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276677 in webkit


Ignore:
Timestamp:
Apr 27, 2021, 4:01:41 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

charset in contentType used in Blob.prototype.slice(start, end, contentType) is lost
​https://bugs.webkit.org/show_bug.cgi?id=225057

Patch by Alex Christensen <​achristensen@webkit.org> on 2021-04-27
Reviewed by Chris Dumez.

Source/WebCore:

When calling Blob.slice, use the content type from the call, not from the sliced-from blob.
This matches Chrome and Firefox.

When no content type is given, browsers disagree on what happens, so keep existing behavior in that case.

Test: fast/files/blob-content-type.html

  • fileapi/Blob.cpp:

(WebCore::Blob::Blob):

  • fileapi/ThreadableBlobRegistry.cpp:

(WebCore::ThreadableBlobRegistry::registerBlobURLForSlice):

  • fileapi/ThreadableBlobRegistry.h:
  • platform/network/BlobRegistry.h:
  • platform/network/BlobRegistryImpl.cpp:

(WebCore::BlobRegistryImpl::registerBlobURLForSlice):

  • platform/network/BlobRegistryImpl.h:

Source/WebKit:

  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::NetworkConnectionToWebProcess::registerBlobURLForSlice):

  • NetworkProcess/NetworkConnectionToWebProcess.h:
  • NetworkProcess/NetworkConnectionToWebProcess.messages.in:
  • NetworkProcess/NetworkProcessPlatformStrategies.cpp:

(WebKit::NetworkProcessPlatformStrategies::createBlobRegistry):

  • WebProcess/FileAPI/BlobRegistryProxy.cpp:

(WebKit::BlobRegistryProxy::registerBlobURLForSlice):

  • WebProcess/FileAPI/BlobRegistryProxy.h:

Source/WebKitLegacy/mac:

  • WebCoreSupport/WebPlatformStrategies.mm:

Source/WebKitLegacy/win:

  • WebCoreSupport/WebPlatformStrategies.cpp:

LayoutTests:

  • fast/files/blob-content-type-expected.txt: Added.
  • fast/files/blob-content-type.html: Added.
Location:
trunk
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r276673 r276677  
     12021-04-27  Alex Christensen  <achristensen@webkit.org>
     2
     3        charset in contentType used in Blob.prototype.slice(start, end, contentType) is lost
     4        https://bugs.webkit.org/show_bug.cgi?id=225057
     5
     6        Reviewed by Chris Dumez.
     7
     8        * fast/files/blob-content-type-expected.txt: Added.
     9        * fast/files/blob-content-type.html: Added.
     10
    1112021-04-27  Aditya Keerthi  <akeerthi@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r276660 r276677  
     12021-04-27  Alex Christensen  <achristensen@webkit.org>
     2
     3        charset in contentType used in Blob.prototype.slice(start, end, contentType) is lost
     4        https://bugs.webkit.org/show_bug.cgi?id=225057
     5
     6        Reviewed by Chris Dumez.
     7
     8        When calling Blob.slice, use the content type from the call, not from the sliced-from blob.
     9        This matches Chrome and Firefox.
     10
     11        When no content type is given, browsers disagree on what happens, so keep existing behavior in that case.
     12
     13        Test: fast/files/blob-content-type.html
     14
     15        * fileapi/Blob.cpp:
     16        (WebCore::Blob::Blob):
     17        * fileapi/ThreadableBlobRegistry.cpp:
     18        (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice):
     19        * fileapi/ThreadableBlobRegistry.h:
     20        * platform/network/BlobRegistry.h:
     21        * platform/network/BlobRegistryImpl.cpp:
     22        (WebCore::BlobRegistryImpl::registerBlobURLForSlice):
     23        * platform/network/BlobRegistryImpl.h:
     24
    1252021-04-27  Alexey Shvayka  <shvaikalesh@gmail.com>
    226
  • trunk/Source/WebCore/fileapi/Blob.cpp

    r273890 r276677  
    161161{
    162162    m_internalURL = BlobURL::createInternalURL();
    163     ThreadableBlobRegistry::registerBlobURLForSlice(m_internalURL, srcURL, start, end);
     163    ThreadableBlobRegistry::registerBlobURLForSlice(m_internalURL, srcURL, start, end, m_type);
    164164}
    165165
  • trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp

    r276230 r276677  
    127127}
    128128
    129 void ThreadableBlobRegistry::registerBlobURLForSlice(const URL& newURL, const URL& srcURL, long long start, long long end)
     129void ThreadableBlobRegistry::registerBlobURLForSlice(const URL& newURL, const URL& srcURL, long long start, long long end, const String& contentType)
    130130{
    131131    if (isMainThread()) {
    132         blobRegistry().registerBlobURLForSlice(newURL, srcURL, start, end);
     132        blobRegistry().registerBlobURLForSlice(newURL, srcURL, start, end, contentType);
    133133        return;
    134134    }
    135135
    136     callOnMainThread([newURL = newURL.isolatedCopy(), srcURL = srcURL.isolatedCopy(), start, end] {
    137         blobRegistry().registerBlobURLForSlice(newURL, srcURL, start, end);
     136    callOnMainThread([newURL = newURL.isolatedCopy(), srcURL = srcURL.isolatedCopy(), start, end, contentType = contentType.isolatedCopy()] {
     137        blobRegistry().registerBlobURLForSlice(newURL, srcURL, start, end, contentType);
    138138    });
    139139}
  • trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.h

    r263830 r276677  
    4545    static void registerBlobURL(SecurityOrigin*, const URL&, const URL& srcURL);
    4646    static void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, const String& fileBackedPath, const String& contentType);
    47     static void registerBlobURLForSlice(const URL& newURL, const URL& srcURL, long long start, long long end);
     47    static void registerBlobURLForSlice(const URL& newURL, const URL& srcURL, long long start, long long end, const String& contentType);
    4848    static void unregisterBlobURL(const URL&);
    4949
  • trunk/Source/WebCore/platform/network/BlobRegistry.h

    r263830 r276677  
    6060
    6161    // Negative start and end values select from the end.
    62     virtual void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end) = 0;
     62    virtual void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end, const String& contentType) = 0;
    6363
    6464    virtual void unregisterBlobURL(const URL&) = 0;
  • trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp

    r270269 r276677  
    179179}
    180180
    181 void BlobRegistryImpl::registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end)
     181void BlobRegistryImpl::registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end, const String& contentType)
    182182{
    183183    ASSERT(isMainThread());
    … …  
    208208
    209209    unsigned long long newLength = end - start;
    210     auto newData = BlobData::create(originalData->contentType());
     210    auto newData = BlobData::create(contentType.isEmpty() ? originalData->contentType() : contentType);
    211211
    212212    appendStorageItems(newData.ptr(), originalData->items(), start, newLength);
  • trunk/Source/WebCore/platform/network/BlobRegistryImpl.h

    r248593 r276677  
    6363    void registerBlobURL(const URL&, const URL& srcURL);
    6464    void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, RefPtr<BlobDataFileReference>&&, const String& contentType);
    65     void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end);
     65    void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end, const String& contentType);
    6666    void unregisterBlobURL(const URL&);
    6767
  • trunk/Source/WebKit/ChangeLog

    r276671 r276677  
     12021-04-27  Alex Christensen  <achristensen@webkit.org>
     2
     3        charset in contentType used in Blob.prototype.slice(start, end, contentType) is lost
     4        https://bugs.webkit.org/show_bug.cgi?id=225057
     5
     6        Reviewed by Chris Dumez.
     7
     8        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     9        (WebKit::NetworkConnectionToWebProcess::registerBlobURLForSlice):
     10        * NetworkProcess/NetworkConnectionToWebProcess.h:
     11        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
     12        * NetworkProcess/NetworkProcessPlatformStrategies.cpp:
     13        (WebKit::NetworkProcessPlatformStrategies::createBlobRegistry):
     14        * WebProcess/FileAPI/BlobRegistryProxy.cpp:
     15        (WebKit::BlobRegistryProxy::registerBlobURLForSlice):
     16        * WebProcess/FileAPI/BlobRegistryProxy.h:
     17
    1182021-04-27  Fujii Hironori  <Hironori.Fujii@sony.com>
    219
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r275846 r276677  
    839839}
    840840
    841 void NetworkConnectionToWebProcess::registerBlobURLForSlice(const URL& url, const URL& srcURL, int64_t start, int64_t end)
     841void NetworkConnectionToWebProcess::registerBlobURLForSlice(const URL& url, const URL& srcURL, int64_t start, int64_t end, const String& contentType)
    842842{
    843843    auto* session = networkSession();
    … …  
    845845        return;
    846846
    847     session->blobRegistry().registerBlobURLForSlice(url, srcURL, start, end);
     847    session->blobRegistry().registerBlobURLForSlice(url, srcURL, start, end, contentType);
    848848}
    849849
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h

    r275846 r276677  
    234234    void registerBlobURLFromURL(const URL&, const URL& srcURL);
    235235    void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, const String& fileBackedPath, const String& contentType);
    236     void registerBlobURLForSlice(const URL&, const URL& srcURL, int64_t start, int64_t end);
     236    void registerBlobURLForSlice(const URL&, const URL& srcURL, int64_t start, int64_t end, const String& contentType);
    237237    void blobSize(const URL&, CompletionHandler<void(uint64_t)>&&);
    238238    void unregisterBlobURL(const URL&);
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in

    r275846 r276677  
    5353    RegisterBlobURLFromURL(URL url, URL srcURL)
    5454    RegisterBlobURLOptionallyFileBacked(URL url, URL srcURL, String fileBackedPath, String contentType)
    55     RegisterBlobURLForSlice(URL url, URL srcURL, int64_t start, int64_t end)
     55    RegisterBlobURLForSlice(URL url, URL srcURL, int64_t start, int64_t end, String contentType)
    5656    UnregisterBlobURL(URL url)
    5757    BlobSize(URL url) -> (uint64_t resultSize) Synchronous
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.cpp

    r263830 r276677  
    6262        void registerBlobURL(const URL&, const URL& srcURL) final { ASSERT_NOT_REACHED(); }
    6363        void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, RefPtr<BlobDataFileReference>&&, const String& contentType) final { ASSERT_NOT_REACHED(); }
    64         void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end) final { ASSERT_NOT_REACHED(); }
     64        void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end, const String& contentType) final { ASSERT_NOT_REACHED(); }
    6565        void unregisterBlobURL(const URL&) final { ASSERT_NOT_REACHED(); }
    6666        unsigned long long blobSize(const URL&) final { ASSERT_NOT_REACHED(); return 0; }
  • trunk/Source/WebKit/WebProcess/FileAPI/BlobRegistryProxy.cpp

    r263830 r276677  
    7070}
    7171
    72 void BlobRegistryProxy::registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end)
     72void BlobRegistryProxy::registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end, const String& contentType)
    7373{
    74     WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLForSlice(url, srcURL, start, end), 0);
     74    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLForSlice(url, srcURL, start, end, contentType), 0);
    7575}
    7676
  • trunk/Source/WebKit/WebProcess/FileAPI/BlobRegistryProxy.h

    r263830 r276677  
    3737    void registerBlobURLOptionallyFileBacked(const URL&, const URL& srcURL, RefPtr<WebCore::BlobDataFileReference>&&, const String& contentType) final;
    3838    void unregisterBlobURL(const URL&) final;
    39     void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end) final;
     39    void registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end, const String& contentType) final;
    4040    unsigned long long blobSize(const URL&) final;
    4141    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) final;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r276652 r276677  
     12021-04-27  Alex Christensen  <achristensen@webkit.org>
     2
     3        charset in contentType used in Blob.prototype.slice(start, end, contentType) is lost
     4        https://bugs.webkit.org/show_bug.cgi?id=225057
     5
     6        Reviewed by Chris Dumez.
     7
     8        * WebCoreSupport/WebPlatformStrategies.mm:
     9
    1102021-04-27  Alex Christensen  <achristensen@webkit.org>
    211
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm

    r274829 r276677  
    8888    void registerBlobURL(const URL& url, const URL& srcURL) final { m_blobRegistry.registerBlobURL(url, srcURL); }
    8989    void registerBlobURLOptionallyFileBacked(const URL& url, const URL& srcURL, RefPtr<BlobDataFileReference>&& reference, const String& contentType) final { m_blobRegistry.registerBlobURLOptionallyFileBacked(url, srcURL, WTFMove(reference), contentType); }
    90     void registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end) final { m_blobRegistry.registerBlobURLForSlice(url, srcURL, start, end); }
     90    void registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end, const String& contentType) final { m_blobRegistry.registerBlobURLForSlice(url, srcURL, start, end, contentType); }
    9191    void unregisterBlobURL(const URL& url) final { m_blobRegistry.unregisterBlobURL(url); }
    9292    unsigned long long blobSize(const URL& url) final { return m_blobRegistry.blobSize(url); }
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r276468 r276677  
     12021-04-27  Alex Christensen  <achristensen@webkit.org>
     2
     3        charset in contentType used in Blob.prototype.slice(start, end, contentType) is lost
     4        https://bugs.webkit.org/show_bug.cgi?id=225057
     5
     6        Reviewed by Chris Dumez.
     7
     8        * WebCoreSupport/WebPlatformStrategies.cpp:
     9
    1102021-04-22  Chris Dumez  <cdumez@apple.com>
    211
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp

    r270808 r276677  
    8585    void registerBlobURL(const URL& url, const URL& srcURL) final { m_blobRegistry.registerBlobURL(url, srcURL); }
    8686    void registerBlobURLOptionallyFileBacked(const URL& url, const URL& srcURL, RefPtr<BlobDataFileReference>&& reference, const String& contentType) final { m_blobRegistry.registerBlobURLOptionallyFileBacked(url, srcURL, WTFMove(reference), contentType); }
    87     void registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end) final { m_blobRegistry.registerBlobURLForSlice(url, srcURL, start, end); }
     87    void registerBlobURLForSlice(const URL& url, const URL& srcURL, long long start, long long end, const String& contentType) final { m_blobRegistry.registerBlobURLForSlice(url, srcURL, start, end, contentType); }
    8888    void unregisterBlobURL(const URL& url) final { m_blobRegistry.unregisterBlobURL(url); }
    8989    unsigned long long blobSize(const URL& url) final { return m_blobRegistry.blobSize(url); }
Note: See TracChangeset for help on using the changeset viewer.