WebKit Bugzilla
Attachment 356913 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-20181209112035.patch (text/plain), 5.39 KB, created by
Rob Buis
on 2018-12-09 02:20:37 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2018-12-09 02:20:37 PST
Size:
5.39 KB
patch
obsolete
>Subversion Revision: 238953 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 5fce4533f61ff5fc50bc6178e290c115e452713e..0fa52df1e344ae262d169b85228efc911d79e157 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/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!). >+ >+ Test: http/tests/xmlhttprequest/supported-xml-content-types.html >+ >+ * platform/network/HTTPParsers.cpp: >+ (WebCore::extractMIMETypeFromMediaType): >+ > 2018-12-07 Rob Buis <rbuis@igalia.com> > > Merge parseAccessControlExposeHeadersAllowList into parseAccessControlAllowList >diff --git a/Source/WebCore/platform/network/HTTPParsers.cpp b/Source/WebCore/platform/network/HTTPParsers.cpp >index 9b018b28c2aa0f7d121ed5bb1876eda8ebdcf111..11eff7033d3204a6b01b359c08935085eae28a0e 100644 >--- a/Source/WebCore/platform/network/HTTPParsers.cpp >+++ b/Source/WebCore/platform/network/HTTPParsers.cpp >@@ -301,14 +301,24 @@ String filenameFromHTTPContentDisposition(const String& value) > > String extractMIMETypeFromMediaType(const String& mediaType) > { >- StringBuilder mimeType; >+ unsigned pos = 0; > unsigned length = mediaType.length(); >- mimeType.reserveCapacity(length); >- for (unsigned i = 0; i < length; i++) { >- UChar c = mediaType[i]; > >- if (c == ';') >+ while (pos < length) { >+ UChar c = mediaType[pos]; >+ if (c != '\t' && c != ' ') > break; >+ ++pos; >+ } >+ >+ if (pos == length) >+ return mediaType; >+ >+ unsigned typeStart = pos; >+ >+ unsigned typeEnd = pos; >+ while (pos < length) { >+ UChar c = mediaType[pos]; > > // 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 +326,16 @@ 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; >+ if (c != '\t' && c != ' ') >+ typeEnd = pos + 1; > >- mimeType.append(c); >+ ++pos; > } > >- 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 ba32eafd019926df4ab4ab03f6bf24d6c0c43188..aba1a6a28e7ef82fb88fe5dbe1c4021597ab770e 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+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!). >+ >+ * http/tests/xmlhttprequest/supported-xml-content-types-expected.txt: >+ * http/tests/xmlhttprequest/supported-xml-content-types.html: >+ > 2018-12-07 Thibault Saunier <tsaunier@igalia.com> > > [WPE][GTK] Implement WebAudioSourceProviderGStreamer to allow bridging MediaStream and the WebAudio APIs >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);
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