URLParser: IPv6 addresses followed by a colon are invalid
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2016 20:18:16 +0000 (20:18 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2016 20:18:16 +0000 (20:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162747

Reviewed by Tim Horton.

Source/WebCore:

Covered by new API tests.

* platform/URLParser.cpp:
(WebCore::URLParser::parseIPv6Host):

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206608 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/URLParser.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

index 08f4d2d..1e5e21f 100644 (file)
@@ -1,3 +1,15 @@
+2016-09-29  Alex Christensen  <achristensen@webkit.org>
+
+        URLParser: IPv6 addresses followed by a colon are invalid
+        https://bugs.webkit.org/show_bug.cgi?id=162747
+
+        Reviewed by Tim Horton.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parseIPv6Host):
+
 2016-09-29  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] scheduler for layout nodes
index ae9cad5..04dbadb 100644 (file)
@@ -2201,7 +2201,7 @@ Optional<URLParser::IPv6Address> URLParser::parseIPv6Host(CodePointIterator<Char
         address[piecePointer++] = value;
         if (c.atEnd())
             break;
-        if (*c != ':')
+        if (piecePointer == 8 || *c != ':')
             return Nullopt;
         advance(c, hostBegin);
     }
index a8b0a21..a1f83fe 100644 (file)
@@ -1,3 +1,13 @@
+2016-09-29  Alex Christensen  <achristensen@webkit.org>
+
+        URLParser: IPv6 addresses followed by a colon are invalid
+        https://bugs.webkit.org/show_bug.cgi?id=162747
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2016-09-29  Alexey Proskuryakov  <ap@apple.com>
 
         Make WKTR short timeout dynamic
index 1e4b9a1..7001f6c 100644 (file)
@@ -736,6 +736,18 @@ TEST_F(URLParserTest, ParserDifferences)
     checkURLDifferences("http://127.%.0.1/",
         {"", "", "", "", 0, "", "", "", "http://127.%.0.1/"},
         {"http", "", "", "127.%.0.1", 0, "/", "", "", "http://127.%.0.1/"});
+    checkURLDifferences("http://[1:2:3:4:5:6:7:8:]/",
+        {"", "", "", "", 0, "", "", "", "http://[1:2:3:4:5:6:7:8:]/"},
+        {"http", "", "", "[1:2:3:4:5:6:7:8:]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:8:]/"});
+    checkURLDifferences("http://[:2:3:4:5:6:7:8:]/",
+        {"", "", "", "", 0, "", "", "", "http://[:2:3:4:5:6:7:8:]/"},
+        {"http", "", "", "[:2:3:4:5:6:7:8:]", 0, "/", "", "", "http://[:2:3:4:5:6:7:8:]/"});
+    checkURLDifferences("http://[1:2:3:4:5:6:7::]/",
+        {"http", "", "", "[1:2:3:4:5:6:7:0]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:0]/"},
+        {"http", "", "", "[1:2:3:4:5:6:7::]", 0, "/", "", "", "http://[1:2:3:4:5:6:7::]/"});
+    checkURLDifferences("http://[1:2:3:4:5:6:7:::]/",
+        {"", "", "", "", 0, "", "", "", "http://[1:2:3:4:5:6:7:::]/"},
+        {"http", "", "", "[1:2:3:4:5:6:7:::]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:::]/"});
 }
 
 TEST_F(URLParserTest, DefaultPort)
@@ -882,6 +894,7 @@ TEST_F(URLParserTest, ParserFailures)
     shouldFail("http://[1234::ab@]");
     shouldFail("http://[1234::ab~]");
     shouldFail("http://[2001::1");
+    shouldFail("http://[1:2:3:4:5:6:7:8~]/");
 }
 
 // These are in the spec but not in the web platform tests.