⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 236528 in webkit


Ignore:
Timestamp:
Sep 26, 2018, 2:58:29 PM (8 years ago)
Author:
achristensen@apple.com
Message:

URLs with mismatched surrogate pairs in the host should fail to parse
https://bugs.webkit.org/show_bug.cgi?id=190005

Reviewed by Chris Dumez.

Source/WebCore:

Elsewhere in the URLParser, when we encounter mismatched surrogate pairs we use the replacement character,
but that just fails later on in domainToASCII, so we may as well just fail.
This behavior matches Chrome, but is unclear in the spec. There are no valid uses of hosts containing mismatched surrogate pairs.
Covered by new API tests.

  • platform/URLParser.cpp:

(WebCore::URLParser::parseHostAndPort):

Tools:

  • TestWebKitAPI/Tests/WebCore/URLParser.cpp:

(TestWebKitAPI::TEST_F):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r236527 r236528  
     12018-09-26  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLs with mismatched surrogate pairs in the host should fail to parse
     4        https://bugs.webkit.org/show_bug.cgi?id=190005
     5
     6        Reviewed by Chris Dumez.
     7
     8        Elsewhere in the URLParser, when we encounter mismatched surrogate pairs we use the replacement character,
     9        but that just fails later on in domainToASCII, so we may as well just fail.
     10        This behavior matches Chrome, but is unclear in the spec.  There are no valid uses of hosts containing mismatched surrogate pairs.
     11        Covered by new API tests.
     12
     13        * platform/URLParser.cpp:
     14        (WebCore::URLParser::parseHostAndPort):
     15
    1162018-09-26  Alex Christensen  <achristensen@webkit.org>
    217
  • trunk/Source/WebCore/platform/URLParser.cpp

    r236527 r236528  
    27542754            syntaxViolation(hostBegin);
    27552755
     2756        if (!U_IS_UNICODE_CHAR(*iterator))
     2757            return false;
    27562758        uint8_t buffer[U8_MAX_LENGTH];
    27572759        int32_t offset = 0;
    2758         UBool error = false;
    2759         U8_APPEND(buffer, offset, U8_MAX_LENGTH, *iterator, error);
    2760         ASSERT_WITH_SECURITY_IMPLICATION(offset <= static_cast<int32_t>(sizeof(buffer)));
    2761         // FIXME: Check error.
     2760        U8_APPEND_UNSAFE(buffer, offset, *iterator);
    27622761        utf8Encoded.append(buffer, offset);
    27632762    }
  • trunk/Tools/ChangeLog

    r236524 r236528  
     12018-09-26  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLs with mismatched surrogate pairs in the host should fail to parse
     4        https://bugs.webkit.org/show_bug.cgi?id=190005
     5
     6        Reviewed by Chris Dumez.
     7
     8        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
     9        (TestWebKitAPI::TEST_F):
     10
    1112018-09-26  Alex Christensen  <achristensen@webkit.org>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

    r233789 r236528  
    12581258    const wchar_t validSurrogateEnd = 0xDD55;
    12591259    const wchar_t invalidSurrogateEnd = 'A';
     1260    const wchar_t replacementCharacter = 0xFFFD;
    12601261    checkURL(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, validSurrogateEnd, '\0'}),
    12611262        {"http", "", "", "w", 0, "/%F0%90%85%95", "", "", "http://w/%F0%90%85%95"}, testTabsValueForSurrogatePairs);
    1262 
     1263    shouldFail(utf16String<10>({'h', 't', 't', 'p', ':', '/', surrogateBegin, invalidSurrogateEnd, '/', '\0'}));
     1264    shouldFail(utf16String<9>({'h', 't', 't', 'p', ':', '/', replacementCharacter, '/', '\0'}));
     1265   
    12631266    // URLParser matches Chrome and Firefox but not URL::parse.
    12641267    checkURLDifferences(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, invalidSurrogateEnd}),
Note: See TracChangeset for help on using the changeset viewer.