Changeset 211067 in webkit


Ignore:
Timestamp:
Jan 23, 2017 3:26:55 PM (7 years ago)
Author:
achristensen@apple.com
Message:

URLParser should fail to parse percent-encoded invalid UTF-8 sequences
https://bugs.webkit.org/show_bug.cgi?id=167330
Source/WebCore:

<rdar://problem/29319962>

Reviewed by Tim Horton.

Covered by new API tests.

  • platform/URLParser.cpp:

(WebCore::containsOnlyASCII):
(WebCore::URLParser::parseHostAndPort):
If UTF-8 decoding fails after percent-decoding the host, fail to parse.
This matches Chrome and Firefox, and it was proposed to the spec in https://github.com/whatwg/url/issues/215

Tools:

Reviewed by Tim Horton.

  • TestWebKitAPI/Tests/WebCore/URLParser.cpp:

(TestWebKitAPI::TEST_F):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r211058 r211067  
     12017-01-23  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser should fail to parse percent-encoded invalid UTF-8 sequences
     4        https://bugs.webkit.org/show_bug.cgi?id=167330
     5        <rdar://problem/29319962>
     6
     7        Reviewed by Tim Horton.
     8
     9        Covered by new API tests.
     10
     11        * platform/URLParser.cpp:
     12        (WebCore::containsOnlyASCII):
     13        (WebCore::URLParser::parseHostAndPort):
     14        If UTF-8 decoding fails after percent-decoding the host, fail to parse.
     15        This matches Chrome and Firefox, and it was proposed to the spec in https://github.com/whatwg/url/issues/215
     16
    1172017-01-23  Alex Christensen  <achristensen@webkit.org>
    218
  • trunk/Source/WebCore/platform/URLParser.cpp

    r211058 r211067  
    24652465ALWAYS_INLINE static bool containsOnlyASCII(const String& string)
    24662466{
     2467    ASSERT(!string.isNull());
    24672468    if (string.is8Bit())
    24682469        return charactersAreAllASCII(string.characters8(), string.length());
     
    26822683    Vector<LChar, defaultInlineBufferSize> percentDecoded = percentDecode(utf8Encoded.data(), utf8Encoded.size(), hostBegin);
    26832684    String domain = String::fromUTF8(percentDecoded.data(), percentDecoded.size());
     2685    if (domain.isNull())
     2686        return false;
    26842687    if (domain != StringView(percentDecoded.data(), percentDecoded.size()))
    26852688        syntaxViolation(hostBegin);
  • trunk/Tools/ChangeLog

    r211058 r211067  
     12017-01-23  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser should fail to parse percent-encoded invalid UTF-8 sequences
     4        https://bugs.webkit.org/show_bug.cgi?id=167330
     5
     6        Reviewed by Tim Horton.
     7
     8        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
     9        (TestWebKitAPI::TEST_F):
     10
    1112017-01-23  Alex Christensen  <achristensen@webkit.org>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

    r211058 r211067  
    788788        {"file", "", "", "", 0, "/pAtH/", "", "", "file:///pAtH/"},
    789789        {"file", "", "", "", 0, "pAtH/", "", "", "file://pAtH/"});
    790    
     790    checkURLDifferences("http://example.com%A0",
     791        {"", "", "", "", 0, "", "", "", "http://example.com%A0"},
     792        {"http", "", "", "example.com%a0", 0, "/", "", "", "http://example.com%a0/"});
     793    checkURLDifferences("http://%E2%98%83",
     794        {"http", "", "", "xn--n3h", 0, "/", "", "", "http://xn--n3h/"},
     795        {"http", "", "", "%e2%98%83", 0, "/", "", "", "http://%e2%98%83/"});
    791796    checkURLDifferences("http://host%73",
    792797        {"http", "", "", "hosts", 0, "/", "", "", "http://hosts/"},
Note: See TracChangeset for help on using the changeset viewer.