Title: [212249] trunk
Revision
212249
Author
[email protected]
Date
2017-02-13 14:52:34 -0800 (Mon, 13 Feb 2017)

Log Message

Percent should be allowed in non-special URL hosts
https://bugs.webkit.org/show_bug.cgi?id=168255

Reviewed by Tim Horton.

LayoutTests/imported/w3c:

* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:

Source/WebCore:

In the last few weeks, the spec has consolidated its sets of code points.
Now forbidden host code points replace the old invalid host code points with
the modification that percents are allowed in non-special hosts because we
percent-encode non-ascii code points in non-special hosts.
See https://url.spec.whatwg.org/#concept-opaque-host-parser

Covered by newly passing web platform tests.

* platform/URLParser.cpp:
(WebCore::isC0Control):
(WebCore::isInUserInfoEncodeSet):
(WebCore::URLParser::hasForbiddenHostCodePoint):
(WebCore::URLParser::parseHostAndPort):
(WebCore::isInvalidDomainCharacter): Deleted.
(WebCore::URLParser::hasInvalidDomainCharacter): Deleted.
* platform/URLParser.h:

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (212248 => 212249)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-13 21:55:55 UTC (rev 212248)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-13 22:52:34 UTC (rev 212249)
@@ -1,3 +1,14 @@
+2017-02-13  Alex Christensen  <[email protected]>
+
+        Percent should be allowed in non-special URL hosts
+        https://bugs.webkit.org/show_bug.cgi?id=168255
+
+        Reviewed by Tim Horton.
+
+        * web-platform-tests/url/a-element-expected.txt:
+        * web-platform-tests/url/a-element-xhtml-expected.txt:
+        * web-platform-tests/url/url-constructor-expected.txt:
+
 2017-02-11  Youenn Fablet  <[email protected]>
 
         Refresh WPT tests up to 06c6c52e05e05483d3c844168a417ee27a554eb7

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt (212248 => 212249)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt	2017-02-13 21:55:55 UTC (rev 212248)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt	2017-02-13 22:52:34 UTC (rev 212249)
@@ -333,7 +333,7 @@
 PASS Parsing: <sc://!"$&'()*+,-.;<=>^_`{|}~/> against <about:blank> 
 PASS Parsing: <sc://\0/> against <about:blank> 
 PASS Parsing: <sc:// /> against <about:blank> 
-FAIL Parsing: <sc://%/> against <about:blank> assert_equals: protocol expected "sc:" but got ":"
+PASS Parsing: <sc://%/> against <about:blank> 
 PASS Parsing: <sc://@/> against <about:blank> 
 PASS Parsing: <sc://te@s:t@/> against <about:blank> 
 PASS Parsing: <sc://:/> against <about:blank> 
@@ -418,8 +418,8 @@
 PASS Parsing: <git+https://github.com/foo/bar> against <about:blank> 
 PASS Parsing: <urn:ietf:rfc:2648> against <about:blank> 
 PASS Parsing: <tag:[email protected],2001:foo/bar> against <about:blank> 
-FAIL Parsing: <non-special://%E2%80%A0/> against <about:blank> assert_equals: protocol expected "non-special:" but got ":"
-FAIL Parsing: <non-special://H%4fSt/path> against <about:blank> assert_equals: protocol expected "non-special:" but got ":"
+PASS Parsing: <non-special://%E2%80%A0/> against <about:blank> 
+PASS Parsing: <non-special://H%4fSt/path> against <about:blank> 
 PASS Parsing: <non-special://[1:2:0:0:5:0:0:0]/> against <about:blank> 
 PASS Parsing: <non-special://[1:2:0:0:0:0:0:3]/> against <about:blank> 
 PASS Parsing: <non-special://[1:2::3]:80/> against <about:blank> 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt (212248 => 212249)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt	2017-02-13 21:55:55 UTC (rev 212248)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt	2017-02-13 22:52:34 UTC (rev 212249)
@@ -333,7 +333,7 @@
 PASS Parsing: <sc://!"$&'()*+,-.;<=>^_`{|}~/> against <about:blank> 
 PASS Parsing: <sc://\0/> against <about:blank> 
 PASS Parsing: <sc:// /> against <about:blank> 
-FAIL Parsing: <sc://%/> against <about:blank> assert_equals: protocol expected "sc:" but got ":"
+PASS Parsing: <sc://%/> against <about:blank> 
 PASS Parsing: <sc://@/> against <about:blank> 
 PASS Parsing: <sc://te@s:t@/> against <about:blank> 
 PASS Parsing: <sc://:/> against <about:blank> 
@@ -418,8 +418,8 @@
 PASS Parsing: <git+https://github.com/foo/bar> against <about:blank> 
 PASS Parsing: <urn:ietf:rfc:2648> against <about:blank> 
 PASS Parsing: <tag:[email protected],2001:foo/bar> against <about:blank> 
-FAIL Parsing: <non-special://%E2%80%A0/> against <about:blank> assert_equals: protocol expected "non-special:" but got ":"
-FAIL Parsing: <non-special://H%4fSt/path> against <about:blank> assert_equals: protocol expected "non-special:" but got ":"
+PASS Parsing: <non-special://%E2%80%A0/> against <about:blank> 
+PASS Parsing: <non-special://H%4fSt/path> against <about:blank> 
 PASS Parsing: <non-special://[1:2:0:0:5:0:0:0]/> against <about:blank> 
 PASS Parsing: <non-special://[1:2:0:0:0:0:0:3]/> against <about:blank> 
 PASS Parsing: <non-special://[1:2::3]:80/> against <about:blank> 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt (212248 => 212249)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt	2017-02-13 21:55:55 UTC (rev 212248)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt	2017-02-13 22:52:34 UTC (rev 212249)
@@ -341,7 +341,7 @@
 PASS Parsing: <sc://!"$&'()*+,-.;<=>^_`{|}~/> against <about:blank> 
 PASS Parsing: <sc://\0/> against <about:blank> 
 PASS Parsing: <sc:// /> against <about:blank> 
-FAIL Parsing: <sc://%/> against <about:blank> Type error
+PASS Parsing: <sc://%/> against <about:blank> 
 PASS Parsing: <sc://@/> against <about:blank> 
 PASS Parsing: <sc://te@s:t@/> against <about:blank> 
 PASS Parsing: <sc://:/> against <about:blank> 
@@ -440,8 +440,8 @@
 PASS Parsing: <git+https://github.com/foo/bar> against <about:blank> 
 PASS Parsing: <urn:ietf:rfc:2648> against <about:blank> 
 PASS Parsing: <tag:[email protected],2001:foo/bar> against <about:blank> 
-FAIL Parsing: <non-special://%E2%80%A0/> against <about:blank> Type error
-FAIL Parsing: <non-special://H%4fSt/path> against <about:blank> Type error
+PASS Parsing: <non-special://%E2%80%A0/> against <about:blank> 
+PASS Parsing: <non-special://H%4fSt/path> against <about:blank> 
 PASS Parsing: <non-special://[1:2:0:0:5:0:0:0]/> against <about:blank> 
 PASS Parsing: <non-special://[1:2:0:0:0:0:0:3]/> against <about:blank> 
 PASS Parsing: <non-special://[1:2::3]:80/> against <about:blank> 

Modified: trunk/Source/WebCore/ChangeLog (212248 => 212249)


--- trunk/Source/WebCore/ChangeLog	2017-02-13 21:55:55 UTC (rev 212248)
+++ trunk/Source/WebCore/ChangeLog	2017-02-13 22:52:34 UTC (rev 212249)
@@ -1,3 +1,27 @@
+2017-02-13  Alex Christensen  <[email protected]>
+
+        Percent should be allowed in non-special URL hosts
+        https://bugs.webkit.org/show_bug.cgi?id=168255
+
+        Reviewed by Tim Horton.
+
+        In the last few weeks, the spec has consolidated its sets of code points.
+        Now forbidden host code points replace the old invalid host code points with
+        the modification that percents are allowed in non-special hosts because we
+        percent-encode non-ascii code points in non-special hosts.
+        See https://url.spec.whatwg.org/#concept-opaque-host-parser
+
+        Covered by newly passing web platform tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::isC0Control):
+        (WebCore::isInUserInfoEncodeSet):
+        (WebCore::URLParser::hasForbiddenHostCodePoint):
+        (WebCore::URLParser::parseHostAndPort):
+        (WebCore::isInvalidDomainCharacter): Deleted.
+        (WebCore::URLParser::hasInvalidDomainCharacter): Deleted.
+        * platform/URLParser.h:
+
 2017-02-13  Anders Carlsson  <[email protected]>
 
         Fix Windows build.

Modified: trunk/Source/WebCore/platform/URLParser.cpp (212248 => 212249)


--- trunk/Source/WebCore/platform/URLParser.cpp	2017-02-13 21:55:55 UTC (rev 212248)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2017-02-13 22:52:34 UTC (rev 212249)
@@ -146,15 +146,14 @@
 enum URLCharacterClass {
     UserInfo = 0x1,
     Default = 0x2,
-    InvalidDomain = 0x4,
+    ForbiddenHost = 0x4,
     QueryPercent = 0x8,
     SlashQuestionOrHash = 0x10,
     ValidScheme = 0x20,
-    ForbiddenHost = 0x40,
 };
 
 static const uint8_t characterClassTable[256] = {
-    UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // 0x0
+    UserInfo | Default | QueryPercent | ForbiddenHost, // 0x0
     UserInfo | Default | QueryPercent, // 0x1
     UserInfo | Default | QueryPercent, // 0x2
     UserInfo | Default | QueryPercent, // 0x3
@@ -163,11 +162,11 @@
     UserInfo | Default | QueryPercent, // 0x6
     UserInfo | Default | QueryPercent, // 0x7
     UserInfo | Default | QueryPercent, // 0x8
-    UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // 0x9
-    UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // 0xA
+    UserInfo | Default | QueryPercent | ForbiddenHost, // 0x9
+    UserInfo | Default | QueryPercent | ForbiddenHost, // 0xA
     UserInfo | Default | QueryPercent, // 0xB
     UserInfo | Default | QueryPercent, // 0xC
-    UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // 0xD
+    UserInfo | Default | QueryPercent | ForbiddenHost, // 0xD
     UserInfo | Default | QueryPercent, // 0xE
     UserInfo | Default | QueryPercent, // 0xF
     UserInfo | Default | QueryPercent, // 0x10
@@ -186,12 +185,12 @@
     UserInfo | Default | QueryPercent, // 0x1D
     UserInfo | Default | QueryPercent, // 0x1E
     UserInfo | Default | QueryPercent, // 0x1F
-    UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // ' '
+    UserInfo | Default | QueryPercent | ForbiddenHost, // ' '
     0, // '!'
     UserInfo | Default | QueryPercent, // '"'
-    UserInfo | Default | InvalidDomain | QueryPercent | SlashQuestionOrHash | ForbiddenHost, // '#'
+    UserInfo | Default | QueryPercent | SlashQuestionOrHash | ForbiddenHost, // '#'
     0, // '$'
-    InvalidDomain | ForbiddenHost, // '%'
+    ForbiddenHost, // '%'
     0, // '&'
     0, // '''
     0, // '('
@@ -201,7 +200,7 @@
     0, // ','
     ValidScheme, // '-'
     ValidScheme, // '.'
-    UserInfo | InvalidDomain | SlashQuestionOrHash | ForbiddenHost, // '/'
+    UserInfo | SlashQuestionOrHash | ForbiddenHost, // '/'
     ValidScheme, // '0'
     ValidScheme, // '1'
     ValidScheme, // '2'
@@ -212,13 +211,13 @@
     ValidScheme, // '7'
     ValidScheme, // '8'
     ValidScheme, // '9'
-    UserInfo | InvalidDomain | ForbiddenHost, // ':'
+    UserInfo | ForbiddenHost, // ':'
     UserInfo, // ';'
     UserInfo | Default | QueryPercent, // '<'
     UserInfo, // '='
     UserInfo | Default | QueryPercent, // '>'
-    UserInfo | Default | InvalidDomain | SlashQuestionOrHash | ForbiddenHost, // '?'
-    UserInfo | InvalidDomain | ForbiddenHost, // '@'
+    UserInfo | Default | SlashQuestionOrHash | ForbiddenHost, // '?'
+    UserInfo | ForbiddenHost, // '@'
     ValidScheme, // 'A'
     ValidScheme, // 'B'
     ValidScheme, // 'C'
@@ -245,9 +244,9 @@
     ValidScheme, // 'X'
     ValidScheme, // 'Y'
     ValidScheme, // 'Z'
-    UserInfo | InvalidDomain | ForbiddenHost, // '['
-    UserInfo | InvalidDomain | SlashQuestionOrHash | ForbiddenHost, // '\\'
-    UserInfo | InvalidDomain | ForbiddenHost, // ']'
+    UserInfo | ForbiddenHost, // '['
+    UserInfo | SlashQuestionOrHash | ForbiddenHost, // '\\'
+    UserInfo | ForbiddenHost, // ']'
     UserInfo, // '^'
     0, // '_'
     UserInfo | Default, // '`'
@@ -418,7 +417,6 @@
 template<typename CharacterType> ALWAYS_INLINE static bool isInSimpleEncodeSet(CharacterType character) { return character > 0x7E || isC0Control(character); }
 template<typename CharacterType> ALWAYS_INLINE static bool isInDefaultEncodeSet(CharacterType character) { return character > 0x7E || characterClassTable[character] & Default; }
 template<typename CharacterType> ALWAYS_INLINE static bool isInUserInfoEncodeSet(CharacterType character) { return character > 0x7E || characterClassTable[character] & UserInfo; }
-template<typename CharacterType> ALWAYS_INLINE static bool isInvalidDomainCharacter(CharacterType character) { return character <= ']' && characterClassTable[character] & InvalidDomain; }
 template<typename CharacterType> ALWAYS_INLINE static bool isPercentOrNonASCII(CharacterType character) { return !isASCII(character) || character == '%'; }
 template<typename CharacterType> ALWAYS_INLINE static bool isSlashQuestionOrHash(CharacterType character) { return character <= '\\' && characterClassTable[character] & SlashQuestionOrHash; }
 template<typename CharacterType> ALWAYS_INLINE static bool isValidSchemeCharacter(CharacterType character) { return character <= 'z' && characterClassTable[character] & ValidScheme; }
@@ -2517,10 +2515,10 @@
     return std::nullopt;
 }
 
-bool URLParser::hasInvalidDomainCharacter(const Vector<LChar, URLParser::defaultInlineBufferSize>& asciiDomain)
+bool URLParser::hasForbiddenHostCodePoint(const Vector<LChar, URLParser::defaultInlineBufferSize>& asciiDomain)
 {
     for (size_t i = 0; i < asciiDomain.size(); ++i) {
-        if (isInvalidDomainCharacter(asciiDomain[i]))
+        if (isForbiddenHostCodePoint(asciiDomain[i]))
             return true;
     }
     return false;
@@ -2614,7 +2612,7 @@
             }
             if (*iterator == ':')
                 break;
-            if (UNLIKELY(isForbiddenHostCodePoint(*iterator)))
+            if (UNLIKELY(isForbiddenHostCodePoint(*iterator) && *iterator != '%'))
                 return false;
             utf8PercentEncode<isInSimpleEncodeSet>(iterator);
         }
@@ -2633,7 +2631,7 @@
                 continue;
             if (*iterator == ':')
                 break;
-            if (isInvalidDomainCharacter(*iterator))
+            if (isForbiddenHostCodePoint(*iterator))
                 return false;
         }
         if (auto address = parseIPv4Host(hostIterator, CodePointIterator<CharacterType>(hostIterator, iterator))) {
@@ -2689,7 +2687,7 @@
     if (domain != StringView(percentDecoded.data(), percentDecoded.size()))
         syntaxViolation(hostBegin);
     auto asciiDomain = domainToASCII(domain, hostBegin);
-    if (!asciiDomain || hasInvalidDomainCharacter(asciiDomain.value()))
+    if (!asciiDomain || hasForbiddenHostCodePoint(asciiDomain.value()))
         return false;
     Vector<LChar, defaultInlineBufferSize>& asciiDomainValue = asciiDomain.value();
     const LChar* asciiDomainCharacters = asciiDomainValue.data();

Modified: trunk/Source/WebCore/platform/URLParser.h (212248 => 212249)


--- trunk/Source/WebCore/platform/URLParser.h	2017-02-13 21:55:55 UTC (rev 212248)
+++ trunk/Source/WebCore/platform/URLParser.h	2017-02-13 22:52:34 UTC (rev 212249)
@@ -98,7 +98,7 @@
     template<typename CharacterType> Vector<LChar, defaultInlineBufferSize> percentDecode(const LChar*, size_t, const CodePointIterator<CharacterType>& iteratorForSyntaxViolationPosition);
     static Vector<LChar, defaultInlineBufferSize> percentDecode(const LChar*, size_t);
     static std::optional<String> formURLDecode(StringView input);
-    static bool hasInvalidDomainCharacter(const Vector<LChar, defaultInlineBufferSize>&);
+    static bool hasForbiddenHostCodePoint(const Vector<LChar, defaultInlineBufferSize>&);
     void percentEncodeByte(uint8_t);
     void appendToASCIIBuffer(UChar32);
     void appendToASCIIBuffer(const char*, size_t);

Modified: trunk/Tools/ChangeLog (212248 => 212249)


--- trunk/Tools/ChangeLog	2017-02-13 21:55:55 UTC (rev 212248)
+++ trunk/Tools/ChangeLog	2017-02-13 22:52:34 UTC (rev 212249)
@@ -1,3 +1,13 @@
+2017-02-13  Alex Christensen  <[email protected]>
+
+        Percent should be allowed in non-special URL hosts
+        https://bugs.webkit.org/show_bug.cgi?id=168255
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2017-02-13  Fujii Hironori  <[email protected]>
 
         Nwtr unexpectedly passes mismatch ref test if the hashes doesn't match but no diff

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (212248 => 212249)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2017-02-13 21:55:55 UTC (rev 212248)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2017-02-13 22:52:34 UTC (rev 212249)
@@ -980,12 +980,8 @@
         {"http", "", "", "f", 10, "/c", "", "", "http://f:10/c"},
         {"http", "", "", "f", 10, "/c", "", "", "http://f:010/c"});
     checkURL("notspecial://HoSt", {"notspecial", "", "", "HoSt", 0, "", "", "", "notspecial://HoSt"});
-    checkURLDifferences("notspecial://H%6FSt",
-        {"", "", "", "", 0, "", "", "", "notspecial://H%6FSt"},
-        {"notspecial", "", "", "H%6FSt", 0, "", "", "", "notspecial://H%6FSt"});
-    checkURLDifferences("notspecial://H%4fSt",
-        {"", "", "", "", 0, "", "", "", "notspecial://H%4fSt"},
-        {"notspecial", "", "", "H%4fSt", 0, "", "", "", "notspecial://H%4fSt"});
+    checkURL("notspecial://H%6FSt", {"notspecial", "", "", "H%6FSt", 0, "", "", "", "notspecial://H%6FSt"});
+    checkURL("notspecial://H%4fSt", {"notspecial", "", "", "H%4fSt", 0, "", "", "", "notspecial://H%4fSt"});
     checkURLDifferences(utf16String(u"notspecial://H😍ßt"),
         {"notspecial", "", "", "H%F0%9F%98%8D%C3%9Ft", 0, "", "", "", "notspecial://H%F0%9F%98%8D%C3%9Ft"},
         {"notspecial", "", "", "xn--hsst-qc83c", 0, "", "", "", "notspecial://xn--hsst-qc83c"}, testTabsValueForSurrogatePairs);
@@ -1073,15 +1069,9 @@
         {"asdf", "", "", "[::a:b:c:d]", 0, "", "", "", "asdf://[::a:b:c:d]"},
         {"asdf", "", "", "[0:0:0:0:a:b:c:d]", 0, "", "", "", "asdf://[0:0:0:0:a:b:c:d]"}, TestTabs::No);
     shouldFail("a://%:a");
-    checkURLDifferences("a://%:/",
-        {"", "", "", "", 0, "", "", "", "a://%:/"},
-        {"a", "", "", "%", 0, "/", "", "", "a://%/"});
-    checkURLDifferences("a://%:",
-        {"", "", "", "", 0, "", "", "", "a://%:"},
-        {"a", "", "", "%", 0, "", "", "", "a://%"});
-    checkURLDifferences("a://%:1/",
-        {"", "", "", "", 0, "", "", "", "a://%:1/"},
-        {"a", "", "", "%", 1, "/", "", "", "a://%:1/"});
+    checkURL("a://%:/", {"a", "", "", "%", 0, "/", "", "", "a://%/"});
+    checkURL("a://%:", {"a", "", "", "%", 0, "", "", "", "a://%"});
+    checkURL("a://%:1/", {"a", "", "", "%", 1, "/", "", "", "a://%:1/"});
     checkURLDifferences("http://%:",
         {"", "", "", "", 0, "", "", "", "http://%:"},
         {"http", "", "", "%", 0, "/", "", "", "http://%/"});
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to