Update MIME type parser
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Jan 2019 19:11:54 +0000 (19:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Jan 2019 19:11:54 +0000 (19:11 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@240591 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/xhr/overridemimetype-blob-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/network/ParsedContentType.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/ParsedContentType.cpp

index 523e4e4..caabb42 100644 (file)
@@ -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
index 7de610d..b84b5e8 100644 (file)
@@ -18,7 +18,7 @@ FAIL 13) MIME types need to be parsed and serialized: text/html;charset='gbk ass
 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"
index e8d9209..6d76ee4 100644 (file)
@@ -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
index e3eabd9..67a433c 100644 (file)
@@ -264,6 +264,8 @@ bool parseContentType(const String& contentType, ReceiverType& receiver, Mode mo
             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;
         }
index e40de57..9190b9e 100644 (file)
@@ -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
index 45b8894..155704a 100644 (file)
@@ -51,7 +51,8 @@ TEST(ParsedContentType, MimeSniff)
 
     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 @@ TEST(ParsedContentType, Rfc2045)
     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));