Changeset 206609 in webkit


Ignore:
Timestamp:
Sep 29, 2016, 1:21:54 PM (9 years ago)
Author:
achristensen@apple.com
Message:

URLParser: make parsing invalid IPv4 addresses more robust and correct
https://bugs.webkit.org/show_bug.cgi?id=162746

Reviewed by Tim Horton.

Source/WebCore:

If parsing an IPv4 address fails, the characters are just treated as a regular domain.

Covered by new API tests.

  • platform/URLParser.cpp:

(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):

Tools:

  • TestWebKitAPI/Tests/WebCore/URLParser.cpp:

(TestWebKitAPI::TEST_F):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206608 r206609  
     12016-09-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser: make parsing invalid IPv4 addresses more robust and correct
     4        https://bugs.webkit.org/show_bug.cgi?id=162746
     5
     6        Reviewed by Tim Horton.
     7
     8        If parsing an IPv4 address fails, the characters are just treated as a regular domain.
     9
     10        Covered by new API tests.
     11
     12        * platform/URLParser.cpp:
     13        (WebCore::URLParser::parseIPv4Number):
     14        (WebCore::URLParser::parseIPv4Host):
     15
    1162016-09-29  Alex Christensen  <achristensen@webkit.org>
    217
  • trunk/Source/WebCore/platform/URLParser.cpp

    r206608 r206609  
    20442044    while (!iterator.atEnd()) {
    20452045        if (*iterator == '.') {
    2046             ++iterator;
    20472046            ASSERT(!value.hasOverflowed());
    20482047            return value.unsafeGet();
     
    21242123        else
    21252124            return Nullopt;
    2126     }
    2127     if (!items.size() || items.size() > 4)
     2125        if (!iterator.atEnd()) {
     2126            if (items.size() >= 4)
     2127                return Nullopt;
     2128            if (*iterator == '.')
     2129                ++iterator;
     2130            else
     2131                return Nullopt;
     2132        }
     2133    }
     2134    if (!iterator.atEnd() || !items.size() || items.size() > 4)
    21282135        return Nullopt;
    21292136    if (items.size() > 2) {
  • trunk/Tools/ChangeLog

    r206608 r206609  
     12016-09-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser: make parsing invalid IPv4 addresses more robust and correct
     4        https://bugs.webkit.org/show_bug.cgi?id=162746
     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

    r206608 r206609  
    290290    checkURL("http://\t//\\///user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
    291291    checkURL("http:/\\user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
     292    checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
     293    checkURL("http://127.0.0.1.", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
     294    checkURL("http://127.0.0.1./", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
    292295
    293296    // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse,
     
    749752        {"", "", "", "", 0, "", "", "", "http://[1:2:3:4:5:6:7:::]/"},
    750753        {"http", "", "", "[1:2:3:4:5:6:7:::]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:::]/"});
     754    checkURLDifferences("http://127.0.0.1~/",
     755        {"http", "", "", "127.0.0.1~", 0, "/", "", "", "http://127.0.0.1~/"},
     756        {"", "", "", "", 0, "", "", "", "http://127.0.0.1~/"});
     757    checkURLDifferences("http://127.0.1~/",
     758        {"http", "", "", "127.0.1~", 0, "/", "", "", "http://127.0.1~/"},
     759        {"", "", "", "", 0, "", "", "", "http://127.0.1~/"});
     760    checkURLDifferences("http://127.0.1./",
     761        {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
     762        {"http", "", "", "127.0.1.", 0, "/", "", "", "http://127.0.1./"});
     763    checkURLDifferences("http://127.0.1.~/",
     764        {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"},
     765        {"", "", "", "", 0, "", "", "", "http://127.0.1.~/"});
     766    checkURLDifferences("http://127.0.1.~",
     767        {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"},
     768        {"", "", "", "", 0, "", "", "", "http://127.0.1.~"});
    751769}
    752770
Note: See TracChangeset for help on using the changeset viewer.