Skip to content
  • commit-queue@webkit.org's avatar
    Blob content type normalization. · 684fac8f
    commit-queue@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=111380
    
    Patch by Victor Costan <costan@gmail.com> on 2013-04-10
    Reviewed by Alexey Proskuryakov.
    
    Source/WebCore:
    
    Tests: http/tests/fast/files/blob-constructor.js
           http/tests/fileapi/xhr-send-form-data-filename-escaping.html
           http/tests/fileapi/xhr-send-form-data-mimetype-normalization.html
    
    * WebCore.exp.in: exported Blob::isNormalizedContentType()
    * bindings/js/JSBlobCustom.cpp:
    (WebCore::JSBlobConstructor::constructJSBlob): remove checks on Blob type, BlobBuilder will normalize it
    * fileapi/Blob.cpp:
    (BlobType): utilities for normalizing a Blob's type according to the File API spec
    (WebCore::BlobType::isValid): content type validity checks in the File API spec
    (WebCore::BlobType::normalize): implements the normalization rules in the File API spec
    (WebCore::BlobType::isNormalized): useful for ASSERTing that a Blob type has been normalized
    (WebCore): implement Blob type normalization according to the File API spec
    (WebCore::Blob::Blob): normalize the Blob type in the data URL
    (WebCore::Blob::slice): normalize the Blob type argument
    * fileapi/Blob.h:
    (BlobType): utilities for normalizing a Blob's type according to the File API spec
    (WebCore::Blob::create): assert that the deserialized Blob's type was normalized
    * fileapi/File.cpp:
    (WebCore::createBlobDataForFileWithType): assert that the File's MIME type is a normalized Blob type
    * fileapi/WebKitBlobBuilder.cpp:
    (WebCore::BlobBuilder::getBlob): normalize the Blob's type before building it
    * platform/network/BlobData.h:
    (WebCore::BlobData::setContentType): assert that the Blob type has been normalized
    * platform/network/FormData.cpp:
    (WebCore::FormData::appendKeyValuePairItems): assert that Blob's type has been normalized
    * platform/network/FormDataBuilder.cpp:
    (WebCore::FormDataBuilder::addContentTypeToMultiPartHeader): assert that the Content-Type field is normalized
    * xml/XMLHttpRequest.cpp: when responseType is blob, normalize Content-Type before passing to Blob constructor
    
    LayoutTests:
    
    * http/tests/fast/files/script-tests/blob-constructor.js: added/updated test cases for Blob type normalization
    * http/tests/fast/files/blob-constructor-expected.txt: added/updated test cases for Blob type normalization
    * http/tests/fileapi/xhr-send-form-data-filename-escaping-expected.txt: Added.
    * http/tests/fileapi/xhr-send-form-data-filename-escaping.html: Added.
    * http/tests/fileapi/xhr-send-form-data-mimetype-normalization-expected.txt: Added.
    * http/tests/fileapi/xhr-send-form-data-mimetype-normalization.html: Added.
    * http/tests/local/formdata/resources/send-form-data-common.js:
    (dumpResponse): return the HTTP response text so it can be used in JS test code
    (sendFormData): passthrough the HTTP response text returned by dumpResponse()
    (testSendingFormData): passthrough the HTTP response text returned by dumpResponse()
    * http/tests/xmlhttprequest/post-blob-content-type-async-expected.txt: updated expectation for invalid Content-Type
    * http/tests/xmlhttprequest/post-blob-content-type-sync-expected.txt: updated expectation for invalid Content-Type
    * http/tests/xmlhttprequest/post-blob-content-type-tests.js: updated expectation for invalid Content-Type
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    684fac8f