Update MIME type parser
https://bugs.webkit.org/show_bug.cgi?id=180526
Patch by Rob Buis <rbuis@igalia.com> on 2019-01-28
Reviewed by Frédéric Wang.
LayoutTests/imported/w3c:
Update improved test expectations.
* web-platform-tests/xhr/overridemimetype-blob-expected.txt:
Source/WebCore:
I overlooked step 11.9.3 [1], for Mimesniff we should not
bail out on missing subtype, but keep trying. Note
that Rfc2045 does require bailing out, as before.
Test: ParsedContentType unittest
[1] https://mimesniff.spec.whatwg.org/#parse-a-mime-type
* platform/network/ParsedContentType.cpp:
(WebCore::parseToken):
(WebCore::parseContentType):
Tools:
* TestWebKitAPI/Tests/WebCore/ParsedContentType.cpp:
(TestWebKitAPI::TEST):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@240591 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog
index 523e4e4a..caabb42 100644
--- a/LayoutTests/imported/w3c/ChangeLog
+++ b/LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,14 @@
+2019-01-28 Rob Buis <rbuis@igalia.com>
+
+ Update MIME type parser
+ https://bugs.webkit.org/show_bug.cgi?id=180526
+
+ Reviewed by Frédéric Wang.
+
+ Update improved test expectations.
+
+ * web-platform-tests/xhr/overridemimetype-blob-expected.txt:
+
2019-01-28 Oriol Brufau <obrufau@igalia.com>
[css-logical] Reject unitless length quirk in 'inset' shorthand
diff --git a/LayoutTests/imported/w3c/web-platform-tests/xhr/overridemimetype-blob-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/xhr/overridemimetype-blob-expected.txt
index 7de610d..b84b5e8 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/xhr/overridemimetype-blob-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/xhr/overridemimetype-blob-expected.txt
@@ -18,7 +18,7 @@
FAIL 14) MIME types need to be parsed and serialized: text/html;charset=gbk' assert_equals: expected "text/html;charset=gbk'" but got "text/html"
FAIL 15) MIME types need to be parsed and serialized: text/html;charset=';charset=GBK assert_equals: expected "text/html;charset='" but got "text/html"
FAIL 16) MIME types need to be parsed and serialized: text/html;test;charset=gbk assert_equals: expected "text/html;charset=gbk" but got "text/html"
-FAIL 17) MIME types need to be parsed and serialized: text/html;test=;charset=gbk assert_equals: expected "text/html;charset=gbk" but got "application/octet-stream"
+FAIL 17) MIME types need to be parsed and serialized: text/html;test=;charset=gbk assert_equals: expected "text/html;charset=gbk" but got "text/html"
FAIL 18) MIME types need to be parsed and serialized: text/html;';charset=gbk assert_equals: expected "text/html;charset=gbk" but got "text/html"
FAIL 19) MIME types need to be parsed and serialized: text/html;";charset=gbk assert_equals: expected "text/html;charset=gbk" but got "text/html"
FAIL 20) MIME types need to be parsed and serialized: text/html ; ; charset=gbk assert_equals: expected "text/html;charset=gbk" but got "text/html"
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index e8d9209..6d76ee4 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2019-01-28 Rob Buis <rbuis@igalia.com>
+
+ Update MIME type parser
+ https://bugs.webkit.org/show_bug.cgi?id=180526
+
+ Reviewed by Frédéric Wang.
+
+ I overlooked step 11.9.3 [1], for Mimesniff we should not
+ bail out on missing subtype, but keep trying. Note
+ that Rfc2045 does require bailing out, as before.
+
+ Test: ParsedContentType unittest
+
+ [1] https://mimesniff.spec.whatwg.org/#parse-a-mime-type
+
+ * platform/network/ParsedContentType.cpp:
+ (WebCore::parseToken):
+ (WebCore::parseContentType):
+
2019-01-28 Michael Catanzaro <mcatanzaro@igalia.com>
Unreviewed follow-up to r240557, restore a call to makeString
diff --git a/Source/WebCore/platform/network/ParsedContentType.cpp b/Source/WebCore/platform/network/ParsedContentType.cpp
index e3eabd9..67a433c 100644
--- a/Source/WebCore/platform/network/ParsedContentType.cpp
+++ b/Source/WebCore/platform/network/ParsedContentType.cpp
@@ -264,6 +264,8 @@
valueRange = parseToken(contentType, index, isNotSemicolon, mode, mode == Mode::MimeSniff);
if (!valueRange) {
+ if (mode == Mode::MimeSniff)
+ continue;
LOG_ERROR("Invalid Content-Type, invalid parameter value.");
return false;
}
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index e40de57..9190b9e 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,13 @@
+2019-01-28 Rob Buis <rbuis@igalia.com>
+
+ Update MIME type parser
+ https://bugs.webkit.org/show_bug.cgi?id=180526
+
+ Reviewed by Frédéric Wang.
+
+ * TestWebKitAPI/Tests/WebCore/ParsedContentType.cpp:
+ (TestWebKitAPI::TEST):
+
2019-01-28 Zalan Bujtas <zalan@apple.com>
[LFC][MarginCollapsing][Quirks] Quirk margin values get propagated through margin collapsing
diff --git a/Tools/TestWebKitAPI/Tests/WebCore/ParsedContentType.cpp b/Tools/TestWebKitAPI/Tests/WebCore/ParsedContentType.cpp
index 45b8894..155704a 100644
--- a/Tools/TestWebKitAPI/Tests/WebCore/ParsedContentType.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebCore/ParsedContentType.cpp
@@ -51,7 +51,8 @@
EXPECT_TRUE(isValidContentType("text/plain;test", Mode::MimeSniff));
EXPECT_TRUE(isValidContentType("text/plain; test", Mode::MimeSniff));
- EXPECT_FALSE(isValidContentType("text/plain;test=", Mode::MimeSniff));
+ EXPECT_TRUE(isValidContentType("text/plain;test=", Mode::MimeSniff));
+ EXPECT_TRUE(isValidContentType("text/plain;test=;test=value", Mode::MimeSniff));
EXPECT_TRUE(isValidContentType("text/plain;test=value", Mode::MimeSniff));
EXPECT_TRUE(isValidContentType("text/plain; test=value", Mode::MimeSniff));
EXPECT_TRUE(isValidContentType("text/plain;test =value", Mode::MimeSniff));
@@ -84,6 +85,7 @@
EXPECT_FALSE(isValidContentType("text/plain;test", Mode::Rfc2045));
EXPECT_FALSE(isValidContentType("text/plain; test", Mode::Rfc2045));
EXPECT_FALSE(isValidContentType("text/plain;test=", Mode::Rfc2045));
+ EXPECT_FALSE(isValidContentType("text/plain;test=;test=value", Mode::Rfc2045));
EXPECT_TRUE(isValidContentType("text/plain;test=value", Mode::Rfc2045));
EXPECT_TRUE(isValidContentType("text/plain; test=value", Mode::Rfc2045));
EXPECT_FALSE(isValidContentType("text/plain;test =value", Mode::Rfc2045));