Title: [206649] trunk
Revision
206649
Author
achristen...@apple.com
Date
2016-09-30 11:48:28 -0700 (Fri, 30 Sep 2016)

Log Message

URLParser: parsing a URL with an empty host and a colon should fail
https://bugs.webkit.org/show_bug.cgi?id=162795

Reviewed by Tim Horton.

Source/WebCore:

Covered by new API tests.

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

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206648 => 206649)


--- trunk/Source/WebCore/ChangeLog	2016-09-30 18:46:28 UTC (rev 206648)
+++ trunk/Source/WebCore/ChangeLog	2016-09-30 18:48:28 UTC (rev 206649)
@@ -1,5 +1,17 @@
 2016-09-30  Alex Christensen  <achristen...@webkit.org>
 
+        URLParser: parsing a URL with an empty host and a colon should fail
+        https://bugs.webkit.org/show_bug.cgi?id=162795
+
+        Reviewed by Tim Horton.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parseHostAndPort):
+
+2016-09-30  Alex Christensen  <achristen...@webkit.org>
+
         URLParser: handle syntax violations in non-UTF-8 encoded queries
         https://bugs.webkit.org/show_bug.cgi?id=162770
 

Modified: trunk/Source/WebCore/platform/URLParser.cpp (206648 => 206649)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-09-30 18:46:28 UTC (rev 206648)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-09-30 18:48:28 UTC (rev 206649)
@@ -2478,6 +2478,8 @@
 {
     if (iterator.atEnd())
         return false;
+    if (*iterator == ':')
+        return false;
     if (*iterator == '[') {
         auto ipv6End = iterator;
         while (!ipv6End.atEnd() && *ipv6End != ']')

Modified: trunk/Tools/ChangeLog (206648 => 206649)


--- trunk/Tools/ChangeLog	2016-09-30 18:46:28 UTC (rev 206648)
+++ trunk/Tools/ChangeLog	2016-09-30 18:48:28 UTC (rev 206649)
@@ -1,5 +1,15 @@
 2016-09-30  Alex Christensen  <achristen...@webkit.org>
 
+        URLParser: parsing a URL with an empty host and a colon should fail
+        https://bugs.webkit.org/show_bug.cgi?id=162795
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2016-09-30  Alex Christensen  <achristen...@webkit.org>
+
         URLParser: handle syntax violations in non-UTF-8 encoded queries
         https://bugs.webkit.org/show_bug.cgi?id=162770
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206648 => 206649)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-30 18:46:28 UTC (rev 206648)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-30 18:48:28 UTC (rev 206649)
@@ -292,6 +292,10 @@
     checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
     checkURL("http://127.0.0.1.", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
     checkURL("http://127.0.0.1./", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
+    checkURL("http://host:123?", {"http", "", "", "host", 123, "/", "", "", "http://host:123/?"});
+    checkURL("http://host:123?query", {"http", "", "", "host", 123, "/", "query", "", "http://host:123/?query"});
+    checkURL("http://host:123#", {"http", "", "", "host", 123, "/", "", "", "http://host:123/#"});
+    checkURL("http://host:123#fragment", {"http", "", "", "host", 123, "/", "", "fragment", "http://host:123/#fragment"});
 
     // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse,
     // and Firefox fails the web platform test differently. Maybe the web platform test ought to be changed.
@@ -707,6 +711,21 @@
     checkURLDifferences("A://",
         {"a", "", "", "", 0, "/", "", "", "a:///"},
         {"a", "", "", "", 0, "//", "", "", "a://"});
+    checkURLDifferences("http://://",
+        {"", "", "", "", 0, "", "", "", "http://://"},
+        {"http", "", "", "", 0, "//", "", "", "http://://"});
+    checkURLDifferences("http://:123?",
+        {"", "", "", "", 0, "", "", "", "http://:123?"},
+        {"http", "", "", "", 123, "/", "", "", "http://:123/?"});
+    checkURLDifferences("http:/:",
+        {"", "", "", "", 0, "", "", "", "http:/:"},
+        {"http", "", "", "", 0, "/", "", "", "http://:/"});
+    checkURLDifferences("asdf://:",
+        {"", "", "", "", 0, "", "", "", "asdf://:"},
+        {"asdf", "", "", "", 0, "", "", "", "asdf://:"});
+    checkURLDifferences("http://:",
+        {"", "", "", "", 0, "", "", "", "http://:"},
+        {"http", "", "", "", 0, "/", "", "", "http://:/"});
     checkRelativeURLDifferences("//C|/foo/bar", "file:///tmp/mock/path",
         {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"},
         {"", "", "", "", 0, "", "", "", "//C|/foo/bar"});
@@ -885,6 +904,7 @@
     shouldFail(String(), "about:blank");
     shouldFail("http://127.0.0.1:abc");
     shouldFail("http://host:abc");
+    shouldFail("http://:abc");
     shouldFail("http://a:@", "about:blank");
     shouldFail("http://:b@", "about:blank");
     shouldFail("http://:@", "about:blank");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to