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

Changeset 236527 in webkit


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

uidna_nameToASCII only needs a buffer capacity of 64
https://bugs.webkit.org/show_bug.cgi?id=190006

Reviewed by Chris Dumez.

Source/WebCore:

This is specified in https://www.unicode.org/reports/tr46/#ToASCII
This is how Chrome and Firefox also behave with long unicode hosts.

  • platform/URLParser.cpp:

(WebCore::URLParser::domainToASCII):

LayoutTests:

  • fast/dom/DOMURL/parsing.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r236519 r236527  
     12018-09-26  Alex Christensen  <achristensen@webkit.org>
     2
     3        uidna_nameToASCII only needs a buffer capacity of 64
     4        https://bugs.webkit.org/show_bug.cgi?id=190006
     5
     6        Reviewed by Chris Dumez.
     7
     8        * fast/dom/DOMURL/parsing.html:
     9
    1102018-09-26  Ryosuke Niwa  <rniwa@webkit.org>
    211
  • trunk/LayoutTests/fast/dom/DOMURL/parsing-expected.txt

    r207162 r236527  
    1515PASS breakDownURL('http://ex%61mple.com/') is 'protocol=http:, host=example.com, pathname=/, origin=http://example.com, toString=http://example.com/'
    1616PASS breakDownURL('http://ex%2fmple.com/') threw exception TypeError: Type error.
     17PASS i is 54
    1718PASS successfullyParsed is true
    1819
  • trunk/LayoutTests/fast/dom/DOMURL/parsing.html

    r207162 r236527  
    5858shouldThrow("breakDownURL('http://ex%2fmple.com/')");
    5959
     60var longUnicodeDomain = "\u1234";
     61var i = 0;
     62try {
     63    for (i = 0; i < 100; ++i) {
     64        longUnicodeDomain += "a"
     65        new URL("http://" + longUnicodeDomain + "/");
     66    }
     67} catch (e) { }
     68shouldBe("i", "54");
     69
    6070</script>
  • trunk/Source/WebCore/ChangeLog

    r236524 r236527  
     12018-09-26  Alex Christensen  <achristensen@webkit.org>
     2
     3        uidna_nameToASCII only needs a buffer capacity of 64
     4        https://bugs.webkit.org/show_bug.cgi?id=190006
     5
     6        Reviewed by Chris Dumez.
     7
     8        This is specified in https://www.unicode.org/reports/tr46/#ToASCII
     9        This is how Chrome and Firefox also behave with long unicode hosts.
     10
     11        * platform/URLParser.cpp:
     12        (WebCore::URLParser::domainToASCII):
     13
    1142018-09-26  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Source/WebCore/platform/URLParser.cpp

    r233789 r236527  
    621621void URLParser::encodeQuery(const Vector<UChar>& source, const TextEncoding& encoding, CodePointIterator<CharacterType> iterator)
    622622{
    623     // FIXME: It is unclear in the spec what to do when encoding fails. The behavior should be specified and tested.
    624623    auto encoded = encoding.encode(StringView(source.data(), source.size()), UnencodableHandling::URLEncodedEntities);
    625624    auto* data = encoded.data();
     
    25692568    }
    25702569   
    2571     UChar hostnameBuffer[defaultInlineBufferSize];
     2570    const size_t maxDomainLength = 64;
     2571    UChar hostnameBuffer[maxDomainLength];
    25722572    UErrorCode error = U_ZERO_ERROR;
    25732573    UIDNAInfo processingDetails = UIDNA_INFO_INITIALIZER;
    2574     int32_t numCharactersConverted = uidna_nameToASCII(&internationalDomainNameTranscoder(), StringView(domain).upconvertedCharacters(), domain.length(), hostnameBuffer, defaultInlineBufferSize, &processingDetails, &error);
    2575     ASSERT(numCharactersConverted <= static_cast<int32_t>(defaultInlineBufferSize));
     2574    int32_t numCharactersConverted = uidna_nameToASCII(&internationalDomainNameTranscoder(), StringView(domain).upconvertedCharacters(), domain.length(), hostnameBuffer, maxDomainLength, &processingDetails, &error);
     2575    ASSERT(numCharactersConverted <= static_cast<int32_t>(maxDomainLength));
    25762576
    25772577    if (U_SUCCESS(error) && !processingDetails.errors) {
     
    25852585        return ascii;
    25862586    }
    2587 
    2588     // FIXME: Check for U_BUFFER_OVERFLOW_ERROR and retry with an allocated buffer.
    25892587    return std::nullopt;
    25902588}
Note: See TracChangeset for help on using the changeset viewer.