WebKit Bugzilla
Attachment 356949 Details for
Bug 8644
: XMLHttpRequest removes spaces from content-types before processing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-8644-20181210092244.patch (text/plain), 10.50 KB, created by
Rob Buis
on 2018-12-10 00:22:45 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2018-12-10 00:22:45 PST
Size:
10.50 KB
patch
obsolete
>Subversion Revision: 239024 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 2b560689ef5cdc45e7ebd16e3dbcf43de79e15ee..f13d003ddc4249b3eff1ab62582a48b254219a86 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,25 @@ >+2018-12-09 Rob Buis <rbuis@igalia.com> >+ >+ XMLHttpRequest removes spaces from content-types before processing >+ https://bugs.webkit.org/show_bug.cgi?id=8644 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Stop trimming white space characters from the middle of >+ type/subtype value. Also make sure whitespace being parsed >+ adheres to LWS definition from RFC 2616, i.e. space or HT. >+ >+ Based on http://crrev.com/416586. >+ >+ Behavior matches Firefox and Chrome. >+ >+ Tests: http/tests/xmlhttprequest/supported-xml-content-types.html >+ web-platform-tests/mimesniff/mime-types/parsing.any.html >+ web-platform-tests/mimesniff/mime-types/parsing.any.worker.html >+ >+ * platform/network/HTTPParsers.cpp: >+ (WebCore::extractMIMETypeFromMediaType): >+ > 2018-12-09 Youenn Fablet <youenn@apple.com> > > Move capture manager from RealtimeMediaSourceCenter to capture factory >diff --git a/Source/WebCore/platform/network/HTTPParsers.cpp b/Source/WebCore/platform/network/HTTPParsers.cpp >index 9b018b28c2aa0f7d121ed5bb1876eda8ebdcf111..f933745ffb3b8b22245857d1137f0278d86b9cf4 100644 >--- a/Source/WebCore/platform/network/HTTPParsers.cpp >+++ b/Source/WebCore/platform/network/HTTPParsers.cpp >@@ -301,14 +301,23 @@ String filenameFromHTTPContentDisposition(const String& value) > > String extractMIMETypeFromMediaType(const String& mediaType) > { >- StringBuilder mimeType; >+ unsigned position = 0; > unsigned length = mediaType.length(); >- mimeType.reserveCapacity(length); >- for (unsigned i = 0; i < length; i++) { >- UChar c = mediaType[i]; > >- if (c == ';') >+ for (; position < length; ++position) { >+ UChar c = mediaType[position]; >+ if (c != '\t' && c != ' ') > break; >+ } >+ >+ if (position == length) >+ return mediaType; >+ >+ unsigned typeStart = position; >+ >+ unsigned typeEnd = position; >+ for (; position < length; ++position) { >+ UChar c = mediaType[position]; > > // While RFC 2616 does not allow it, other browsers allow multiple values in the HTTP media > // type header field, Content-Type. In such cases, the media type string passed here may contain >@@ -316,22 +325,14 @@ String extractMIMETypeFromMediaType(const String& mediaType) > // which prevents it from simply failing to parse such types altogether. Later for better > // compatibility we could consider using the first or last valid MIME type instead. > // See https://bugs.webkit.org/show_bug.cgi?id=25352 for more discussion. >- if (c == ',') >+ if (c == ',' || c == ';') > break; > >- // FIXME: The following is not correct. RFC 2616 allows linear white space before and >- // after the MIME type, but not within the MIME type itself. And linear white space >- // includes only a few specific ASCII characters; a small subset of isSpaceOrNewline. >- // See https://bugs.webkit.org/show_bug.cgi?id=8644 for a bug tracking part of this. >- if (isSpaceOrNewline(c)) >- continue; >- >- mimeType.append(c); >+ if (c != '\t' && c != ' ') >+ typeEnd = position + 1; > } > >- if (mimeType.length() == length) >- return mediaType; >- return mimeType.toString(); >+ return mediaType.substring(typeStart, typeEnd - typeStart); > } > > String extractCharsetFromMediaType(const String& mediaType) >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 202893917e53d9aaa0af273fc573667ad8a8ea56..ec3fdbdbfef6d0ce199814904967e0ae0eac8e8e 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2018-12-09 Rob Buis <rbuis@igalia.com> >+ >+ XMLHttpRequest removes spaces from content-types before processing >+ https://bugs.webkit.org/show_bug.cgi?id=8644 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update improved test expectation and remove comment. >+ >+ * http/tests/xmlhttprequest/supported-xml-content-types-expected.txt: >+ * http/tests/xmlhttprequest/supported-xml-content-types.html: >+ > 2018-12-09 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r239010. >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index c9bfe6214271411a524d66dc09a3d6975b12cdbf..7cb4071e47f067f192d234fac74e8471d69cd295 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,15 @@ >+2018-12-09 Rob Buis <rbuis@igalia.com> >+ >+ XMLHttpRequest removes spaces from content-types before processing >+ https://bugs.webkit.org/show_bug.cgi?id=8644 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update improved test expectations. >+ >+ * web-platform-tests/mimesniff/mime-types/parsing.any-expected.txt: >+ * web-platform-tests/mimesniff/mime-types/parsing.any.worker-expected.txt: >+ > 2018-12-05 Youenn Fablet <youenn@apple.com> > > [iOS] Layout Test imported/w3c/web-platform-tests/service-workers/service-worker/fetch-cors-xhr.https.html is a flaky failure >diff --git a/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types-expected.txt b/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types-expected.txt >index 2308e39813e62146bb2bfc5c3cfff18449d4383c..3da35e7a139665236fcd2210bb03114034add09a 100644 >--- a/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types-expected.txt >+++ b/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types-expected.txt >@@ -46,7 +46,7 @@ PASS -- testing: image/png -- responseXML: null > > PASS -- testing: invalid -- responseXML: null > >-FAIL (got document -- response type: foo bar/baz+xml) -- testing: foo bar/baz+xml -- responseXML: [object XMLDocument] >+PASS -- testing: foo bar/baz+xml -- responseXML: null > > PASS -- testing: foo[bar/baz+xml -- responseXML: null > >diff --git a/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html b/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html >index 30ea214cb9547441010d74192cf9687c7b85c690..c827a2a87e03df1349168abbc16fc59857df84e6 100644 >--- a/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html >+++ b/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html >@@ -65,8 +65,6 @@ testXMLType("image/png", false); > // invalid types > testXMLType("invalid", false); > >-// FIXME: our code intentionally skips spaces, that seems wrong to me. >-// https://bugs.webkit.org/show_bug.cgi?id=8644 > testXMLType("foo bar/baz+xml", false); > > testXMLType("foo[bar/baz+xml", false); >diff --git a/LayoutTests/imported/w3c/web-platform-tests/mimesniff/mime-types/parsing.any-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/mimesniff/mime-types/parsing.any-expected.txt >index f1ea2aa8f0e7ac2b368fe9f226be941972a5bc3e..847cc5efca31cf16145a4eb757683adbf580ac9b 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/mimesniff/mime-types/parsing.any-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/mimesniff/mime-types/parsing.any-expected.txt >@@ -231,9 +231,9 @@ FAIL x/x;x=" > PASS x/x;x=" > ";bonus=x (Request/Response) > PASS /x (Blob/File) >-FAIL /x (Request/Response) assert_equals: expected "" but got "/x" >+PASS /x (Request/Response) > PASS x/ (Blob/File) >-FAIL x/ (Request/Response) assert_equals: expected "" but got "x/" >+PASS x/ (Request/Response) > FAIL x/x;=x;bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got "" > FAIL x/x;=x;bonus=x (Request/Response) assert_equals: expected "x/x;bonus=x" but got "x/x" > FAIL x/x;x=;bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got "" >@@ -241,9 +241,9 @@ FAIL x/x;x=;bonus=x (Request/Response) assert_equals: expected "x/x;bonus=x" bu > FAIL x/x;x="";bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got "" > FAIL x/x;x="";bonus=x (Request/Response) assert_equals: expected "x/x;bonus=x" but got "x/x" > PASS /x (Blob/File) >-FAIL /x (Request/Response) assert_equals: expected "" but got "/x" >+PASS /x (Request/Response) > PASS x/ (Blob/File) >-FAIL x/ (Request/Response) assert_equals: expected "" but got "x/" >+PASS x/ (Request/Response) > FAIL x/x;=x;bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got "" > FAIL x/x;=x;bonus=x (Request/Response) assert_equals: expected "x/x;bonus=x" but got "x/x" > FAIL x/x;x=;bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got "" >diff --git a/LayoutTests/imported/w3c/web-platform-tests/mimesniff/mime-types/parsing.any.worker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/mimesniff/mime-types/parsing.any.worker-expected.txt >index fb1107e0ed810483ad9de340ba06650d1f3a4b37..7d3ce040ed50b2e98048373d2d7e2351d2092e22 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/mimesniff/mime-types/parsing.any.worker-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/mimesniff/mime-types/parsing.any.worker-expected.txt >@@ -231,9 +231,9 @@ FAIL x/x;x=" > PASS x/x;x=" > ";bonus=x (Request/Response) > FAIL /x (Blob/File) Can't find variable: File >-FAIL /x (Request/Response) assert_equals: expected "" but got "/x" >+PASS /x (Request/Response) > FAIL x/ (Blob/File) Can't find variable: File >-FAIL x/ (Request/Response) assert_equals: expected "" but got "x/" >+PASS x/ (Request/Response) > FAIL x/x;=x;bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got "" > FAIL x/x;=x;bonus=x (Request/Response) assert_equals: expected "x/x;bonus=x" but got "x/x" > FAIL x/x;x=;bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got "" >@@ -241,9 +241,9 @@ FAIL x/x;x=;bonus=x (Request/Response) assert_equals: expected "x/x;bonus=x" bu > FAIL x/x;x="";bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got "" > FAIL x/x;x="";bonus=x (Request/Response) assert_equals: expected "x/x;bonus=x" but got "x/x" > FAIL /x (Blob/File) Can't find variable: File >-FAIL /x (Request/Response) assert_equals: expected "" but got "/x" >+PASS /x (Request/Response) > FAIL x/ (Blob/File) Can't find variable: File >-FAIL x/ (Request/Response) assert_equals: expected "" but got "x/" >+PASS x/ (Request/Response) > FAIL x/x;=x;bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got "" > FAIL x/x;=x;bonus=x (Request/Response) assert_equals: expected "x/x;bonus=x" but got "x/x" > FAIL x/x;x=;bonus=x (Blob/File) assert_equals: Blob expected "x/x;bonus=x" but got ""
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 8644
:
356913
|
356914
|
356915
|
356919
|
356920
|
356921
|
356949
|
356971