Changeset 206614 in webkit


Ignore:
Timestamp:
Sep 29, 2016, 2:20:43 PM (9 years ago)
Author:
achristensen@apple.com
Message:

URLParser should correctly parse ports with leading 0's
https://bugs.webkit.org/show_bug.cgi?id=162752

Reviewed by Tim Horton.

Source/WebCore:

Covered by new API tests.

  • platform/URLParser.cpp:

(WebCore::URLParser::parsePort):

Tools:

  • TestWebKitAPI/Tests/WebCore/URLParser.cpp:

(TestWebKitAPI::TEST_F):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206611 r206614  
     12016-09-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser should correctly parse ports with leading 0's
     4        https://bugs.webkit.org/show_bug.cgi?id=162752
     5
     6        Reviewed by Tim Horton.
     7
     8        Covered by new API tests.
     9
     10        * platform/URLParser.cpp:
     11        (WebCore::URLParser::parsePort):
     12
    1132016-09-29  Commit Queue  <commit-queue@webkit.org>
    214
  • trunk/Source/WebCore/platform/URLParser.cpp

    r206609 r206614  
    23622362        return true;
    23632363    }
     2364    bool seenDigit = false;
     2365    bool seenMultipleDigits = false;
     2366    bool leadingZeros = false;
    23642367    for (; !iterator.atEnd(); ++iterator) {
    23652368        if (UNLIKELY(isTabOrNewline(*iterator))) {
     
    23682371        }
    23692372        if (isASCIIDigit(*iterator)) {
     2373            if (*iterator == '0' && !seenDigit)
     2374                leadingZeros = true;
     2375            if (seenDigit)
     2376                seenMultipleDigits = true;
     2377            seenDigit = true;
    23702378            port = port * 10 + *iterator - '0';
    23712379            if (port > std::numeric_limits<uint16_t>::max())
     
    23742382            return false;
    23752383    }
     2384
     2385    if (port && leadingZeros)
     2386        syntaxViolation(colonIterator);
     2387   
     2388    if (!port && seenMultipleDigits)
     2389        syntaxViolation(colonIterator);
    23762390
    23772391    if (UNLIKELY(isDefaultPort(parsedDataView(0, m_url.m_schemeEnd), port)))
  • trunk/Tools/ChangeLog

    r206609 r206614  
     12016-09-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser should correctly parse ports with leading 0's
     4        https://bugs.webkit.org/show_bug.cgi?id=162752
     5
     6        Reviewed by Tim Horton.
     7
     8        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
     9        (TestWebKitAPI::TEST_F):
     10
    1112016-09-29  Alex Christensen  <achristensen@webkit.org>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

    r206609 r206614  
    397397    checkRelativeURL(String(), "http://webkit.org/", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"});
    398398    checkRelativeURL("https://@test@test@example:800\\path@end", "http://doesnotmatter/", {"", "", "", "", 0, "", "", "", "https://@test@test@example:800\\path@end"});
     399    checkRelativeURL("http://f:0/c", "http://example.org/foo/bar", {"http", "", "", "f", 0, "/c", "", "", "http://f:0/c"});
    399400
    400401    // The checking of slashes in SpecialAuthoritySlashes needed to get this to pass contradicts what is in the spec,
     
    767768        {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"},
    768769        {"", "", "", "", 0, "", "", "", "http://127.0.1.~"});
     770    checkRelativeURLDifferences("http://f:000/c", "http://example.org/foo/bar",
     771        {"http", "", "", "f", 0, "/c", "", "", "http://f:0/c"},
     772        {"http", "", "", "f", 0, "/c", "", "", "http://f:000/c"});
     773    checkRelativeURLDifferences("http://f:010/c", "http://example.org/foo/bar",
     774        {"http", "", "", "f", 10, "/c", "", "", "http://f:10/c"},
     775        {"http", "", "", "f", 10, "/c", "", "", "http://f:010/c"});
    769776}
    770777
Note: See TracChangeset for help on using the changeset viewer.