Title: [245983] trunk
Revision
245983
Author
achristen...@apple.com
Date
2019-05-31 13:56:40 -0700 (Fri, 31 May 2019)

Log Message

URLParser::parseIPv6Host should properly parse 0's around compression
https://bugs.webkit.org/show_bug.cgi?id=198424

Reviewed by Tim Horton.

Source/WTF:

* wtf/URLParser.cpp:
(WTF::URLParser::parseIPv6Host):

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (245982 => 245983)


--- trunk/Source/WTF/ChangeLog	2019-05-31 20:55:25 UTC (rev 245982)
+++ trunk/Source/WTF/ChangeLog	2019-05-31 20:56:40 UTC (rev 245983)
@@ -1,5 +1,15 @@
 2019-05-31  Alex Christensen  <achristen...@webkit.org>
 
+        URLParser::parseIPv6Host should properly parse 0's around compression
+        https://bugs.webkit.org/show_bug.cgi?id=198424
+
+        Reviewed by Tim Horton.
+
+        * wtf/URLParser.cpp:
+        (WTF::URLParser::parseIPv6Host):
+
+2019-05-31  Alex Christensen  <achristen...@webkit.org>
+
         URLParser::parseHostAndPort should not allow non-port characters after an ipv6 host
         https://bugs.webkit.org/show_bug.cgi?id=198428
         <rdar://problem/51209196>

Modified: trunk/Source/WTF/wtf/URLParser.cpp (245982 => 245983)


--- trunk/Source/WTF/wtf/URLParser.cpp	2019-05-31 20:55:25 UTC (rev 245982)
+++ trunk/Source/WTF/wtf/URLParser.cpp	2019-05-31 20:56:40 UTC (rev 245983)
@@ -2401,6 +2401,8 @@
     IPv6Address address = {{0, 0, 0, 0, 0, 0, 0, 0}};
     size_t piecePointer = 0;
     Optional<size_t> compressPointer;
+    bool previousValueWasZero = false;
+    bool immediatelyAfterCompress = false;
 
     if (*c == ':') {
         advance(c, hostBegin);
@@ -2411,6 +2413,7 @@
         advance(c, hostBegin);
         ++piecePointer;
         compressPointer = piecePointer;
+        immediatelyAfterCompress = true;
     }
     
     while (!c.atEnd()) {
@@ -2422,6 +2425,9 @@
             advance(c, hostBegin);
             ++piecePointer;
             compressPointer = piecePointer;
+            immediatelyAfterCompress = true;
+            if (previousValueWasZero)
+                syntaxViolation(hostBegin);
             continue;
         }
         if (piecePointer == 6 || (compressPointer && piecePointer < 6)) {
@@ -2451,7 +2457,8 @@
             advance(c, hostBegin);
         }
         
-        if (UNLIKELY((value && leadingZeros) || (!value && length > 1)))
+        previousValueWasZero = !value;
+        if (UNLIKELY((value && leadingZeros) || (previousValueWasZero && (length > 1 || immediatelyAfterCompress))))
             syntaxViolation(hostBegin);
 
         address[piecePointer++] = value;
@@ -2460,6 +2467,8 @@
         if (piecePointer == 8 || *c != ':')
             return WTF::nullopt;
         advance(c, hostBegin);
+
+        immediatelyAfterCompress = false;
     }
     
     if (!c.atEnd())

Modified: trunk/Tools/ChangeLog (245982 => 245983)


--- trunk/Tools/ChangeLog	2019-05-31 20:55:25 UTC (rev 245982)
+++ trunk/Tools/ChangeLog	2019-05-31 20:56:40 UTC (rev 245983)
@@ -1,5 +1,15 @@
 2019-05-31  Alex Christensen  <achristen...@webkit.org>
 
+        URLParser::parseIPv6Host should properly parse 0's around compression
+        https://bugs.webkit.org/show_bug.cgi?id=198424
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WTF/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2019-05-31  Alex Christensen  <achristen...@webkit.org>
+
         URLParser::parseHostAndPort should not allow non-port characters after an ipv6 host
         https://bugs.webkit.org/show_bug.cgi?id=198428
         <rdar://problem/51209196>

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp (245982 => 245983)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp	2019-05-31 20:55:25 UTC (rev 245982)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp	2019-05-31 20:56:40 UTC (rev 245983)
@@ -230,6 +230,17 @@
     checkURL("about:blank", {"about", "", "", "", 0, "blank", "", "", "about:blank"});
     checkURL("about:blank?query", {"about", "", "", "", 0, "blank", "query", "", "about:blank?query"});
     checkURL("about:blank#fragment", {"about", "", "", "", 0, "blank", "", "fragment", "about:blank#fragment"});
+    checkURL("http://[0::0]/", {"http", "", "", "[::]", 0, "/", "", "", "http://[::]/"});
+    checkURL("http://[0::]/", {"http", "", "", "[::]", 0, "/", "", "", "http://[::]/"});
+    checkURL("http://[::]/", {"http", "", "", "[::]", 0, "/", "", "", "http://[::]/"});
+    checkURL("http://[::0]/", {"http", "", "", "[::]", 0, "/", "", "", "http://[::]/"});
+    checkURL("http://[::0:0]/", {"http", "", "", "[::]", 0, "/", "", "", "http://[::]/"});
+    checkURL("http://[f::0:0]/", {"http", "", "", "[f::]", 0, "/", "", "", "http://[f::]/"});
+    checkURL("http://[f:0::f]/", {"http", "", "", "[f::f]", 0, "/", "", "", "http://[f::f]/"});
+    checkURL("http://[::0:ff]/", {"http", "", "", "[::ff]", 0, "/", "", "", "http://[::ff]/"});
+    checkURL("http://[::00:0:0:0]/", {"http", "", "", "[::]", 0, "/", "", "", "http://[::]/"});
+    checkURL("http://[::0:00:0:0]/", {"http", "", "", "[::]", 0, "/", "", "", "http://[::]/"});
+    checkURL("http://[::0:0.0.0.0]/", {"http", "", "", "[::]", 0, "/", "", "", "http://[::]/"});
     checkURL("http://[0:f::f:f:0:0]", {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"});
     checkURL("http://[0:f:0:0:f::]", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"});
     checkURL("http://[::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"});
@@ -1228,6 +1239,7 @@
     shouldFail("http://[a:b:c:d:e:f:127.0.-0.1]");
     shouldFail("asdf://space In\aHost");
     shouldFail("asdf://[0:0:0:0:a:b:c:d");
+    shouldFail("http://[::0:0.0.00000.0]/");
 }
 
 // These are in the spec but not in the web platform tests.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to