[Webkit-unassigned] [Bug 225057] New: charset in contentType used in Blob.prototype.slice(start, end, contentType) is lost

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Apr 26 09:28:55 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=225057

            Bug ID: 225057
           Summary: charset in contentType used in
                    Blob.prototype.slice(start, end, contentType) is lost
           Product: WebKit
           Version: Safari 14
          Hardware: Mac (Intel)
                OS: macOS 10.15
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: DOM
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: rwaldron at salesforce.com

When running the following case in any Safari release, the portion of the contentType argument ";charset=utf-8" is missing from the content-type header when the response is received: 


    const blob = new Blob([`<style></style>`], { type: 'text/html' });
    const normalizedBlob = blob.slice(0, blob.size, `text/html;charset=utf-8`);
    const url = URL.createObjectURL(normalizedBlob);
    const xhr = new XMLHttpRequest();
    xhr.addEventListener('load', () => {
      console.log('(xhr-get) content-type', xhr.getResponseHeader('content-type'));
    });
    xhr.open('GET', url);
    xhr.send();


    fetch(url)
      .then(response => {
        console.log('(fetch) content-type', response.headers.get('content-type'))
      });


Expected output: 

    "(xhr-get) content-type", "text/html;charset=utf-8"
    "(fetch) content-type", "text/html;charset=utf-8"


Actual output: 

    "(xhr-get) content-type", "text/html"
    "(fetch) content-type", "text/html"


The expected output appears correct in Chrome (+ Edge) and Firefox 


I've made the test case available here: https://jsfiddle.net/rwaldron/acnxz7sv/

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210426/70631cfe/attachment.htm>


More information about the webkit-unassigned mailing list