Changeset 212249 in webkit


Ignore:
Timestamp:
Feb 13, 2017, 2:52:34 PM (8 years ago)
Author:
achristensen@apple.com
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):

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/LayoutTests/imported/w3c/ChangeLog

    r212202 r212249  
     12017-02-13  Alex Christensen  <achristensen@webkit.org>
     2
     3        Percent should be allowed in non-special URL hosts
     4        https://bugs.webkit.org/show_bug.cgi?id=168255
     5
     6        Reviewed by Tim Horton.
     7
     8        * web-platform-tests/url/a-element-expected.txt:
     9        * web-platform-tests/url/a-element-xhtml-expected.txt:
     10        * web-platform-tests/url/url-constructor-expected.txt:
     11
    1122017-02-11  Youenn Fablet  <youennf@gmail.com>
    213
  • TabularUnified trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt

    r212202 r212249  
    334334PASS Parsing: <sc://\0/> against <about:blank>
    335335PASS Parsing: <sc:// /> against <about:blank>
    336 FAIL Parsing: <sc://%/> against <about:blank> assert_equals: protocol expected "sc:" but got ":"
     336PASS Parsing: <sc://%/> against <about:blank>
    337337PASS Parsing: <sc://@/> against <about:blank>
    338338PASS Parsing: <sc://te@s:t@/> against <about:blank>
     
    419419PASS Parsing: <urn:ietf:rfc:2648> against <about:blank>
    420420PASS Parsing: <tag:joe@example.org,2001:foo/bar> against <about:blank>
    421 FAIL Parsing: <non-special://%E2%80%A0/> against <about:blank> assert_equals: protocol expected "non-special:" but got ":"
    422 FAIL Parsing: <non-special://H%4fSt/path> against <about:blank> assert_equals: protocol expected "non-special:" but got ":"
     421PASS Parsing: <non-special://%E2%80%A0/> against <about:blank>
     422PASS Parsing: <non-special://H%4fSt/path> against <about:blank>
    423423PASS Parsing: <non-special://[1:2:0:0:5:0:0:0]/> against <about:blank>
    424424PASS Parsing: <non-special://[1:2:0:0:0:0:0:3]/> against <about:blank>
  • TabularUnified trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt

    r212202 r212249  
    334334PASS Parsing: <sc://\0/> against <about:blank>
    335335PASS Parsing: <sc:// /> against <about:blank>
    336 FAIL Parsing: <sc://%/> against <about:blank> assert_equals: protocol expected "sc:" but got ":"
     336PASS Parsing: <sc://%/> against <about:blank>
    337337PASS Parsing: <sc://@/> against <about:blank>
    338338PASS Parsing: <sc://te@s:t@/> against <about:blank>
     
    419419PASS Parsing: <urn:ietf:rfc:2648> against <about:blank>
    420420PASS Parsing: <tag:joe@example.org,2001:foo/bar> against <about:blank>
    421 FAIL Parsing: <non-special://%E2%80%A0/> against <about:blank> assert_equals: protocol expected "non-special:" but got ":"
    422 FAIL Parsing: <non-special://H%4fSt/path> against <about:blank> assert_equals: protocol expected "non-special:" but got ":"
     421PASS Parsing: <non-special://%E2%80%A0/> against <about:blank>
     422PASS Parsing: <non-special://H%4fSt/path> against <about:blank>
    423423PASS Parsing: <non-special://[1:2:0:0:5:0:0:0]/> against <about:blank>
    424424PASS Parsing: <non-special://[1:2:0:0:0:0:0:3]/> against <about:blank>
  • TabularUnified trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt

    r212202 r212249  
    342342PASS Parsing: <sc://\0/> against <about:blank>
    343343PASS Parsing: <sc:// /> against <about:blank>
    344 FAIL Parsing: <sc://%/> against <about:blank> Type error
     344PASS Parsing: <sc://%/> against <about:blank>
    345345PASS Parsing: <sc://@/> against <about:blank>
    346346PASS Parsing: <sc://te@s:t@/> against <about:blank>
     
    441441PASS Parsing: <urn:ietf:rfc:2648> against <about:blank>
    442442PASS Parsing: <tag:joe@example.org,2001:foo/bar> against <about:blank>
    443 FAIL Parsing: <non-special://%E2%80%A0/> against <about:blank> Type error
    444 FAIL Parsing: <non-special://H%4fSt/path> against <about:blank> Type error
     443PASS Parsing: <non-special://%E2%80%A0/> against <about:blank>
     444PASS Parsing: <non-special://H%4fSt/path> against <about:blank>
    445445PASS Parsing: <non-special://[1:2:0:0:5:0:0:0]/> against <about:blank>
    446446PASS Parsing: <non-special://[1:2:0:0:0:0:0:3]/> against <about:blank>
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r212243 r212249  
     12017-02-13  Alex Christensen  <achristensen@webkit.org>
     2
     3        Percent should be allowed in non-special URL hosts
     4        https://bugs.webkit.org/show_bug.cgi?id=168255
     5
     6        Reviewed by Tim Horton.
     7
     8        In the last few weeks, the spec has consolidated its sets of code points.
     9        Now forbidden host code points replace the old invalid host code points with
     10        the modification that percents are allowed in non-special hosts because we
     11        percent-encode non-ascii code points in non-special hosts.
     12        See https://url.spec.whatwg.org/#concept-opaque-host-parser
     13
     14        Covered by newly passing web platform tests.
     15
     16        * platform/URLParser.cpp:
     17        (WebCore::isC0Control):
     18        (WebCore::isInUserInfoEncodeSet):
     19        (WebCore::URLParser::hasForbiddenHostCodePoint):
     20        (WebCore::URLParser::parseHostAndPort):
     21        (WebCore::isInvalidDomainCharacter): Deleted.
     22        (WebCore::URLParser::hasInvalidDomainCharacter): Deleted.
     23        * platform/URLParser.h:
     24
    1252017-02-13  Anders Carlsson  <andersca@apple.com>
    226
  • TabularUnified trunk/Source/WebCore/platform/URLParser.cpp

    r211638 r212249  
    147147    UserInfo = 0x1,
    148148    Default = 0x2,
    149     InvalidDomain = 0x4,
     149    ForbiddenHost = 0x4,
    150150    QueryPercent = 0x8,
    151151    SlashQuestionOrHash = 0x10,
    152152    ValidScheme = 0x20,
    153     ForbiddenHost = 0x40,
    154153};
    155154
    156155static const uint8_t characterClassTable[256] = {
    157     UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // 0x0
     156    UserInfo | Default | QueryPercent | ForbiddenHost, // 0x0
    158157    UserInfo | Default | QueryPercent, // 0x1
    159158    UserInfo | Default | QueryPercent, // 0x2
     
    164163    UserInfo | Default | QueryPercent, // 0x7
    165164    UserInfo | Default | QueryPercent, // 0x8
    166     UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // 0x9
    167     UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // 0xA
     165    UserInfo | Default | QueryPercent | ForbiddenHost, // 0x9
     166    UserInfo | Default | QueryPercent | ForbiddenHost, // 0xA
    168167    UserInfo | Default | QueryPercent, // 0xB
    169168    UserInfo | Default | QueryPercent, // 0xC
    170     UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // 0xD
     169    UserInfo | Default | QueryPercent | ForbiddenHost, // 0xD
    171170    UserInfo | Default | QueryPercent, // 0xE
    172171    UserInfo | Default | QueryPercent, // 0xF
     
    187186    UserInfo | Default | QueryPercent, // 0x1E
    188187    UserInfo | Default | QueryPercent, // 0x1F
    189     UserInfo | Default | InvalidDomain | QueryPercent | ForbiddenHost, // ' '
     188    UserInfo | Default | QueryPercent | ForbiddenHost, // ' '
    190189    0, // '!'
    191190    UserInfo | Default | QueryPercent, // '"'
    192     UserInfo | Default | InvalidDomain | QueryPercent | SlashQuestionOrHash | ForbiddenHost, // '#'
     191    UserInfo | Default | QueryPercent | SlashQuestionOrHash | ForbiddenHost, // '#'
    193192    0, // '$'
    194     InvalidDomain | ForbiddenHost, // '%'
     193    ForbiddenHost, // '%'
    195194    0, // '&'
    196195    0, // '''
     
    202201    ValidScheme, // '-'
    203202    ValidScheme, // '.'
    204     UserInfo | InvalidDomain | SlashQuestionOrHash | ForbiddenHost, // '/'
     203    UserInfo | SlashQuestionOrHash | ForbiddenHost, // '/'
    205204    ValidScheme, // '0'
    206205    ValidScheme, // '1'
     
    213212    ValidScheme, // '8'
    214213    ValidScheme, // '9'
    215     UserInfo | InvalidDomain | ForbiddenHost, // ':'
     214    UserInfo | ForbiddenHost, // ':'
    216215    UserInfo, // ';'
    217216    UserInfo | Default | QueryPercent, // '<'
    218217    UserInfo, // '='
    219218    UserInfo | Default | QueryPercent, // '>'
    220     UserInfo | Default | InvalidDomain | SlashQuestionOrHash | ForbiddenHost, // '?'
    221     UserInfo | InvalidDomain | ForbiddenHost, // '@'
     219    UserInfo | Default | SlashQuestionOrHash | ForbiddenHost, // '?'
     220    UserInfo | ForbiddenHost, // '@'
    222221    ValidScheme, // 'A'
    223222    ValidScheme, // 'B'
     
    246245    ValidScheme, // 'Y'
    247246    ValidScheme, // 'Z'
    248     UserInfo | InvalidDomain | ForbiddenHost, // '['
    249     UserInfo | InvalidDomain | SlashQuestionOrHash | ForbiddenHost, // '\\'
    250     UserInfo | InvalidDomain | ForbiddenHost, // ']'
     247    UserInfo | ForbiddenHost, // '['
     248    UserInfo | SlashQuestionOrHash | ForbiddenHost, // '\\'
     249    UserInfo | ForbiddenHost, // ']'
    251250    UserInfo, // '^'
    252251    0, // '_'
     
    419418template<typename CharacterType> ALWAYS_INLINE static bool isInDefaultEncodeSet(CharacterType character) { return character > 0x7E || characterClassTable[character] & Default; }
    420419template<typename CharacterType> ALWAYS_INLINE static bool isInUserInfoEncodeSet(CharacterType character) { return character > 0x7E || characterClassTable[character] & UserInfo; }
    421 template<typename CharacterType> ALWAYS_INLINE static bool isInvalidDomainCharacter(CharacterType character) { return character <= ']' && characterClassTable[character] & InvalidDomain; }
    422420template<typename CharacterType> ALWAYS_INLINE static bool isPercentOrNonASCII(CharacterType character) { return !isASCII(character) || character == '%'; }
    423421template<typename CharacterType> ALWAYS_INLINE static bool isSlashQuestionOrHash(CharacterType character) { return character <= '\\' && characterClassTable[character] & SlashQuestionOrHash; }
     
    25182516}
    25192517
    2520 bool URLParser::hasInvalidDomainCharacter(const Vector<LChar, URLParser::defaultInlineBufferSize>& asciiDomain)
     2518bool URLParser::hasForbiddenHostCodePoint(const Vector<LChar, URLParser::defaultInlineBufferSize>& asciiDomain)
    25212519{
    25222520    for (size_t i = 0; i < asciiDomain.size(); ++i) {
    2523         if (isInvalidDomainCharacter(asciiDomain[i]))
     2521        if (isForbiddenHostCodePoint(asciiDomain[i]))
    25242522            return true;
    25252523    }
     
    26152613            if (*iterator == ':')
    26162614                break;
    2617             if (UNLIKELY(isForbiddenHostCodePoint(*iterator)))
     2615            if (UNLIKELY(isForbiddenHostCodePoint(*iterator) && *iterator != '%'))
    26182616                return false;
    26192617            utf8PercentEncode<isInSimpleEncodeSet>(iterator);
     
    26342632            if (*iterator == ':')
    26352633                break;
    2636             if (isInvalidDomainCharacter(*iterator))
     2634            if (isForbiddenHostCodePoint(*iterator))
    26372635                return false;
    26382636        }
     
    26902688        syntaxViolation(hostBegin);
    26912689    auto asciiDomain = domainToASCII(domain, hostBegin);
    2692     if (!asciiDomain || hasInvalidDomainCharacter(asciiDomain.value()))
     2690    if (!asciiDomain || hasForbiddenHostCodePoint(asciiDomain.value()))
    26932691        return false;
    26942692    Vector<LChar, defaultInlineBufferSize>& asciiDomainValue = asciiDomain.value();
  • TabularUnified trunk/Source/WebCore/platform/URLParser.h

    r211621 r212249  
    9999    static Vector<LChar, defaultInlineBufferSize> percentDecode(const LChar*, size_t);
    100100    static std::optional<String> formURLDecode(StringView input);
    101     static bool hasInvalidDomainCharacter(const Vector<LChar, defaultInlineBufferSize>&);
     101    static bool hasForbiddenHostCodePoint(const Vector<LChar, defaultInlineBufferSize>&);
    102102    void percentEncodeByte(uint8_t);
    103103    void appendToASCIIBuffer(UChar32);
  • TabularUnified trunk/Tools/ChangeLog

    r212237 r212249  
     12017-02-13  Alex Christensen  <achristensen@webkit.org>
     2
     3        Percent should be allowed in non-special URL hosts
     4        https://bugs.webkit.org/show_bug.cgi?id=168255
     5
     6        Reviewed by Tim Horton.
     7
     8        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
     9        (TestWebKitAPI::TEST_F):
     10
    1112017-02-13  Fujii Hironori  <Hironori.Fujii@sony.com>
    212
  • TabularUnified trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

    r211719 r212249  
    981981        {"http", "", "", "f", 10, "/c", "", "", "http://f:010/c"});
    982982    checkURL("notspecial://HoSt", {"notspecial", "", "", "HoSt", 0, "", "", "", "notspecial://HoSt"});
    983     checkURLDifferences("notspecial://H%6FSt",
    984         {"", "", "", "", 0, "", "", "", "notspecial://H%6FSt"},
    985         {"notspecial", "", "", "H%6FSt", 0, "", "", "", "notspecial://H%6FSt"});
    986     checkURLDifferences("notspecial://H%4fSt",
    987         {"", "", "", "", 0, "", "", "", "notspecial://H%4fSt"},
    988         {"notspecial", "", "", "H%4fSt", 0, "", "", "", "notspecial://H%4fSt"});
     983    checkURL("notspecial://H%6FSt", {"notspecial", "", "", "H%6FSt", 0, "", "", "", "notspecial://H%6FSt"});
     984    checkURL("notspecial://H%4fSt", {"notspecial", "", "", "H%4fSt", 0, "", "", "", "notspecial://H%4fSt"});
    989985    checkURLDifferences(utf16String(u"notspecial://H😍ßt"),
    990986        {"notspecial", "", "", "H%F0%9F%98%8D%C3%9Ft", 0, "", "", "", "notspecial://H%F0%9F%98%8D%C3%9Ft"},
     
    10741070        {"asdf", "", "", "[0:0:0:0:a:b:c:d]", 0, "", "", "", "asdf://[0:0:0:0:a:b:c:d]"}, TestTabs::No);
    10751071    shouldFail("a://%:a");
    1076     checkURLDifferences("a://%:/",
    1077         {"", "", "", "", 0, "", "", "", "a://%:/"},
    1078         {"a", "", "", "%", 0, "/", "", "", "a://%/"});
    1079     checkURLDifferences("a://%:",
    1080         {"", "", "", "", 0, "", "", "", "a://%:"},
    1081         {"a", "", "", "%", 0, "", "", "", "a://%"});
    1082     checkURLDifferences("a://%:1/",
    1083         {"", "", "", "", 0, "", "", "", "a://%:1/"},
    1084         {"a", "", "", "%", 1, "/", "", "", "a://%:1/"});
     1072    checkURL("a://%:/", {"a", "", "", "%", 0, "/", "", "", "a://%/"});
     1073    checkURL("a://%:", {"a", "", "", "%", 0, "", "", "", "a://%"});
     1074    checkURL("a://%:1/", {"a", "", "", "%", 1, "/", "", "", "a://%:1/"});
    10851075    checkURLDifferences("http://%:",
    10861076        {"", "", "", "", 0, "", "", "", "http://%:"},
Note: See TracChangeset for help on using the changeset viewer.