When parsing an IPv4 address, wait until after deciding it is indeed an IPv4 address...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jul 2019 19:15:04 +0000 (19:15 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jul 2019 19:15:04 +0000 (19:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199628

Reviewed by Brady Eidson.

Source/WTF:

Otherwise, we sometimes report syntax violations on things that are not IPv4 addresses and don't have syntax violations.
I added a unit test with one such URL that used to cause an assertion.

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

Tools:

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

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

Source/WTF/ChangeLog
Source/WTF/wtf/URLParser.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp

index 7daa26f..e1f6502 100644 (file)
@@ -1,5 +1,18 @@
 2019-07-09  Alex Christensen  <achristensen@webkit.org>
 
+        When parsing an IPv4 address, wait until after deciding it is indeed an IPv4 address before reporting syntax violations
+        https://bugs.webkit.org/show_bug.cgi?id=199628
+
+        Reviewed by Brady Eidson.
+
+        Otherwise, we sometimes report syntax violations on things that are not IPv4 addresses and don't have syntax violations.
+        I added a unit test with one such URL that used to cause an assertion.
+
+        * wtf/URLParser.cpp:
+        (WTF::URLParser::parseIPv4Host):
+
+2019-07-09  Alex Christensen  <achristensen@webkit.org>
+
         Remove invalid assertion in URLParser::domainToASCII
         https://bugs.webkit.org/show_bug.cgi?id=199624
 
index c6b3e7d..b353e73 100644 (file)
@@ -2294,7 +2294,7 @@ Expected<URLParser::IPv4Address, URLParser::IPv4ParsingError> URLParser::parseIP
         if (!iterator.atEnd() && *iterator == '.') {
             ++iterator;
             if (iterator.atEnd())
-                syntaxViolation(iteratorForSyntaxViolationPosition);
+                didSeeSyntaxViolation = true;
             else if (*iterator == '.')
                 return makeUnexpected(IPv4ParsingError::NotIPv4);
         }
index 076c062..5d6da02 100644 (file)
@@ -1,5 +1,15 @@
 2019-07-09  Alex Christensen  <achristensen@webkit.org>
 
+        When parsing an IPv4 address, wait until after deciding it is indeed an IPv4 address before reporting syntax violations
+        https://bugs.webkit.org/show_bug.cgi?id=199628
+
+        Reviewed by Brady Eidson.
+
+        * TestWebKitAPI/Tests/WTF/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2019-07-09  Alex Christensen  <achristensen@webkit.org>
+
         Remove invalid assertion in URLParser::domainToASCII
         https://bugs.webkit.org/show_bug.cgi?id=199624
 
index d56683d..cd749b7 100644 (file)
@@ -345,6 +345,7 @@ TEST_F(WTF_URLParser, Basic)
     checkURL("http://127.0.0.1:/\tpath", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"});
     checkURL("http://127.0.0.1:123", {"http", "", "", "127.0.0.1", 123, "/", "", "", "http://127.0.0.1:123/"});
     checkURL("http://127.0.0.1:", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
+    checkURL("ws://08./", {"ws", "", "", "08.", 0, "/", "", "", "ws://08./"});
     checkURL("http://[0:f::f:f:0:0]:123/path", {"http", "", "", "[0:f::f:f:0:0]", 123, "/path", "", "", "http://[0:f::f:f:0:0]:123/path"});
     checkURL("http://[0:f::f:f:0:0]:123", {"http", "", "", "[0:f::f:f:0:0]", 123, "/", "", "", "http://[0:f::f:f:0:0]:123/"});
     checkURL("http://[0:f:0:0:f:\t:]:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"});