Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (206608 => 206609)
--- trunk/Source/WebCore/ChangeLog 2016-09-29 20:18:16 UTC (rev 206608)
+++ trunk/Source/WebCore/ChangeLog 2016-09-29 20:21:54 UTC (rev 206609)
@@ -1,5 +1,20 @@
2016-09-29 Alex Christensen <achristen...@webkit.org>
+ URLParser: make parsing invalid IPv4 addresses more robust and correct
+ https://bugs.webkit.org/show_bug.cgi?id=162746
+
+ Reviewed by Tim Horton.
+
+ 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):
+
+2016-09-29 Alex Christensen <achristen...@webkit.org>
+
URLParser: IPv6 addresses followed by a colon are invalid
https://bugs.webkit.org/show_bug.cgi?id=162747
Modified: trunk/Source/WebCore/platform/URLParser.cpp (206608 => 206609)
--- trunk/Source/WebCore/platform/URLParser.cpp 2016-09-29 20:18:16 UTC (rev 206608)
+++ trunk/Source/WebCore/platform/URLParser.cpp 2016-09-29 20:21:54 UTC (rev 206609)
@@ -2043,7 +2043,6 @@
bool didSeeSyntaxViolation = false;
while (!iterator.atEnd()) {
if (*iterator == '.') {
- ++iterator;
ASSERT(!value.hasOverflowed());
return value.unsafeGet();
}
@@ -2123,8 +2122,16 @@
items.append(item.value());
else
return Nullopt;
+ if (!iterator.atEnd()) {
+ if (items.size() >= 4)
+ return Nullopt;
+ if (*iterator == '.')
+ ++iterator;
+ else
+ return Nullopt;
+ }
}
- if (!items.size() || items.size() > 4)
+ if (!iterator.atEnd() || !items.size() || items.size() > 4)
return Nullopt;
if (items.size() > 2) {
for (size_t i = 0; i < items.size() - 2; i++) {
Modified: trunk/Tools/ChangeLog (206608 => 206609)
--- trunk/Tools/ChangeLog 2016-09-29 20:18:16 UTC (rev 206608)
+++ trunk/Tools/ChangeLog 2016-09-29 20:21:54 UTC (rev 206609)
@@ -1,5 +1,15 @@
2016-09-29 Alex Christensen <achristen...@webkit.org>
+ URLParser: make parsing invalid IPv4 addresses more robust and correct
+ https://bugs.webkit.org/show_bug.cgi?id=162746
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+ (TestWebKitAPI::TEST_F):
+
+2016-09-29 Alex Christensen <achristen...@webkit.org>
+
URLParser: IPv6 addresses followed by a colon are invalid
https://bugs.webkit.org/show_bug.cgi?id=162747
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206608 => 206609)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-29 20:18:16 UTC (rev 206608)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-29 20:21:54 UTC (rev 206609)
@@ -289,6 +289,9 @@
checkURL("http:////\t////user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://u...@webkit.org:99/?foo"});
checkURL("http://\t//\\///user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://u...@webkit.org:99/?foo"});
checkURL("http:/\\user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://u...@webkit.org:99/?foo"});
+ 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./"});
// 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.
@@ -748,6 +751,21 @@
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:::]/"});
+ checkURLDifferences("http://127.0.0.1~/",
+ {"http", "", "", "127.0.0.1~", 0, "/", "", "", "http://127.0.0.1~/"},
+ {"", "", "", "", 0, "", "", "", "http://127.0.0.1~/"});
+ checkURLDifferences("http://127.0.1~/",
+ {"http", "", "", "127.0.1~", 0, "/", "", "", "http://127.0.1~/"},
+ {"", "", "", "", 0, "", "", "", "http://127.0.1~/"});
+ checkURLDifferences("http://127.0.1./",
+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
+ {"http", "", "", "127.0.1.", 0, "/", "", "", "http://127.0.1./"});
+ checkURLDifferences("http://127.0.1.~/",
+ {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"},
+ {"", "", "", "", 0, "", "", "", "http://127.0.1.~/"});
+ checkURLDifferences("http://127.0.1.~",
+ {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"},
+ {"", "", "", "", 0, "", "", "", "http://127.0.1.~"});
}
TEST_F(URLParserTest, DefaultPort)
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes