Changeset 276986 in webkit


Ignore:
Timestamp:
May 4, 2021 3:37:08 PM (15 months ago)
Author:
Chris Dumez
Message:

Blob contentType with charset renders html as plain text
https://bugs.webkit.org/show_bug.cgi?id=225226

Reviewed by Alex Christensen.

Source/WebCore:

Our code would use the Blob's Content-Type (media type) as a MIME type internally. As a result, if the Blob's
media type would contain anything besides the MIME type (e.g. a charget), then it would lead to failures.

Test: fast/files/blob-with-charget-as-main-resource.html

  • platform/network/BlobResourceHandle.cpp:

(WebCore::BlobResourceHandle::notifyResponseOnSuccess):

  • platform/network/HTTPParsers.h:

Source/WebKit:

Our code would use the Blob's Content-Type (media type) as a MIME type internally. As a result, if the Blob's
media type would contain anything besides the MIME type (e.g. a charget), then it would lead to failures.

  • NetworkProcess/NetworkDataTaskBlob.cpp:

(WebKit::NetworkDataTaskBlob::dispatchDidReceiveResponse):

LayoutTests:

Add layout test coverage.

  • fast/files/blob-with-charget-as-main-resource-expected.html: Added.
  • fast/files/blob-with-charget-as-main-resource.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r276984 r276986  
     12021-05-04  Chris Dumez  <cdumez@apple.com>
     2
     3        Blob contentType with charset renders html as plain text
     4        https://bugs.webkit.org/show_bug.cgi?id=225226
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add layout test coverage.
     9
     10        * fast/files/blob-with-charget-as-main-resource-expected.html: Added.
     11        * fast/files/blob-with-charget-as-main-resource.html: Added.
     12
    1132021-05-04  Cameron McCormack  <heycam@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r276984 r276986  
     12021-05-04  Chris Dumez  <cdumez@apple.com>
     2
     3        Blob contentType with charset renders html as plain text
     4        https://bugs.webkit.org/show_bug.cgi?id=225226
     5
     6        Reviewed by Alex Christensen.
     7
     8        Our code would use the Blob's Content-Type (media type) as a MIME type internally. As a result, if the Blob's
     9        media type would contain anything besides the MIME type (e.g. a charget), then it would lead to failures.
     10
     11        Test: fast/files/blob-with-charget-as-main-resource.html
     12
     13        * platform/network/BlobResourceHandle.cpp:
     14        (WebCore::BlobResourceHandle::notifyResponseOnSuccess):
     15        * platform/network/HTTPParsers.h:
     16
    1172021-05-04  Cameron McCormack  <heycam@apple.com>
    218
  • trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp

    r266611 r276986  
    570570
    571571    bool isRangeRequest = m_rangeOffset != kPositionNotSpecified;
    572     ResourceResponse response(firstRequest().url(), m_blobData->contentType(), m_totalRemainingSize, String());
     572    ResourceResponse response(firstRequest().url(), extractMIMETypeFromMediaType(m_blobData->contentType()), m_totalRemainingSize, String());
    573573    response.setHTTPStatusCode(isRangeRequest ? httpPartialContent : httpOK);
    574574    response.setHTTPStatusText(isRangeRequest ? httpPartialContentText : httpOKText);
  • trunk/Source/WebCore/platform/network/HTTPParsers.h

    r266087 r276986  
    8080Optional<WallTime> parseHTTPDate(const String&);
    8181String filenameFromHTTPContentDisposition(const String&);
    82 String extractMIMETypeFromMediaType(const String&);
     82WEBCORE_EXPORT String extractMIMETypeFromMediaType(const String&);
    8383String extractCharsetFromMediaType(const String&);
    8484XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String& failureReason, unsigned& failurePosition, String& reportURL);
  • trunk/Source/WebKit/ChangeLog

    r276983 r276986  
     12021-05-04  Chris Dumez  <cdumez@apple.com>
     2
     3        Blob contentType with charset renders html as plain text
     4        https://bugs.webkit.org/show_bug.cgi?id=225226
     5
     6        Reviewed by Alex Christensen.
     7
     8        Our code would use the Blob's Content-Type (media type) as a MIME type internally. As a result, if the Blob's
     9        media type would contain anything besides the MIME type (e.g. a charget), then it would lead to failures.
     10
     11        * NetworkProcess/NetworkDataTaskBlob.cpp:
     12        (WebKit::NetworkDataTaskBlob::dispatchDidReceiveResponse):
     13
    1142021-05-04  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp

    r270638 r276986  
    256256
    257257    Ref<NetworkDataTaskBlob> protectedThis(*this);
    258     ResourceResponse response(m_firstRequest.url(), errorCode != Error::NoError ? "text/plain" : m_blobData->contentType(), errorCode != Error::NoError ? 0 : m_totalRemainingSize, String());
     258    ResourceResponse response(m_firstRequest.url(), errorCode != Error::NoError ? "text/plain" : extractMIMETypeFromMediaType(m_blobData->contentType()), errorCode != Error::NoError ? 0 : m_totalRemainingSize, String());
    259259    switch (errorCode) {
    260260    case Error::NoError: {
Note: See TracChangeset for help on using the changeset viewer.