Log Message
URLParser should parse ports after IPv4 and IPv6 hosts https://bugs.webkit.org/show_bug.cgi?id=161731
Reviewed by Brady Eidson. Source/WebCore: Covered by new API tests. * platform/URLParser.cpp: (WebCore::URLParser::parsePort): (WebCore::URLParser::parseHost): Tools: * TestWebKitAPI/Tests/WebCore/URLParser.cpp: (TestWebKitAPI::TEST_F):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (205668 => 205669)
--- trunk/Source/WebCore/ChangeLog 2016-09-08 22:16:49 UTC (rev 205668)
+++ trunk/Source/WebCore/ChangeLog 2016-09-08 22:28:48 UTC (rev 205669)
@@ -1,5 +1,18 @@
2016-09-08 Alex Christensen <achristen...@webkit.org>
+ URLParser should parse ports after IPv4 and IPv6 hosts
+ https://bugs.webkit.org/show_bug.cgi?id=161731
+
+ Reviewed by Brady Eidson.
+
+ Covered by new API tests.
+
+ * platform/URLParser.cpp:
+ (WebCore::URLParser::parsePort):
+ (WebCore::URLParser::parseHost):
+
+2016-09-08 Alex Christensen <achristen...@webkit.org>
+
URLParser should correctly handle \ in path
https://bugs.webkit.org/show_bug.cgi?id=161762
Modified: trunk/Source/WebCore/platform/URLParser.cpp (205668 => 205669)
--- trunk/Source/WebCore/platform/URLParser.cpp 2016-09-08 22:16:49 UTC (rev 205668)
+++ trunk/Source/WebCore/platform/URLParser.cpp 2016-09-08 22:28:48 UTC (rev 205669)
@@ -1355,7 +1355,11 @@
bool URLParser::parsePort(StringView::CodePoints::Iterator& iterator, const StringView::CodePoints::Iterator& end)
{
uint32_t port = 0;
- ASSERT(iterator != end);
+ if (iterator == end) {
+ m_url.m_portEnd = m_buffer.length();
+ return true;
+ }
+ m_buffer.append(':');
for (; iterator != end; ++iterator) {
if (isTabOrNewline(*iterator))
continue;
@@ -1375,6 +1379,7 @@
} else
m_buffer.appendNumber(port);
+ m_url.m_portEnd = m_buffer.length();
return true;
}
@@ -1390,8 +1395,15 @@
if (auto address = parseIPv6Host(iterator, ipv6End)) {
serializeIPv6(address.value(), m_buffer);
m_url.m_hostEnd = m_buffer.length();
- // FIXME: Handle the port correctly.
- m_url.m_portEnd = m_buffer.length();
+ if (ipv6End != end) {
+ ++ipv6End;
+ if (ipv6End != end && *ipv6End == ':') {
+ ++ipv6End;
+ return parsePort(ipv6End, end);
+ }
+ m_url.m_portEnd = m_buffer.length();
+ return true;
+ }
return true;
}
}
@@ -1421,9 +1433,12 @@
if (auto address = parseIPv4Host(asciiDomainCodePoints.begin(), asciiDomainCodePoints.end())) {
serializeIPv4(address.value(), m_buffer);
m_url.m_hostEnd = m_buffer.length();
- // FIXME: Handle the port correctly.
- m_url.m_portEnd = m_buffer.length();
- return true;
+ if (iterator == end) {
+ m_url.m_portEnd = m_buffer.length();
+ return true;
+ }
+ ++iterator;
+ return parsePort(iterator, end);
}
m_buffer.append(asciiDomain.value());
@@ -1433,11 +1448,7 @@
++iterator;
while (iterator != end && isTabOrNewline(*iterator))
++iterator;
- if (iterator != end) {
- m_buffer.append(':');
- if (!parsePort(iterator, end))
- return false;
- }
+ return parsePort(iterator, end);
}
m_url.m_portEnd = m_buffer.length();
return true;
@@ -1497,7 +1508,7 @@
bool URLParser::enabled()
{
- return urlParserEnabled;
+ return true;
}
} // namespace WebCore
Modified: trunk/Tools/ChangeLog (205668 => 205669)
--- trunk/Tools/ChangeLog 2016-09-08 22:16:49 UTC (rev 205668)
+++ trunk/Tools/ChangeLog 2016-09-08 22:28:48 UTC (rev 205669)
@@ -1,5 +1,15 @@
2016-09-08 Alex Christensen <achristen...@webkit.org>
+ URLParser should parse ports after IPv4 and IPv6 hosts
+ https://bugs.webkit.org/show_bug.cgi?id=161731
+
+ Reviewed by Brady Eidson.
+
+ * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+ (TestWebKitAPI::TEST_F):
+
+2016-09-08 Alex Christensen <achristen...@webkit.org>
+
URLParser should correctly handle \ in path
https://bugs.webkit.org/show_bug.cgi?id=161762
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (205668 => 205669)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-08 22:16:49 UTC (rev 205668)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-08 22:28:48 UTC (rev 205669)
@@ -179,6 +179,19 @@
checkURL("http://host/a%20B", {"http", "", "", "host", 0, "/a%20B", "", "", "http://host/a%20B"});
checkURL("http://host?q=@ <>!#fragment", {"http", "", "", "host", 0, "/", "q=@%20%3C%3E!", "fragment", "http://host/?q=@%20%3C%3E!#fragment"});
checkURL("http://user:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
+ checkURL("http://127.0.0.1:10100/path", {"http", "", "", "127.0.0.1", 10100, "/path", "", "", "http://127.0.0.1:10100/path"});
+ checkURL("http://127.0.0.1:/path", {"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("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::f:f:0:0]:/path", {"http", "", "", "[0:f::f:f:0:0]", 0, "/path", "", "", "http://[0:f::f:f:0:0]/path"});
+ 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://host:10100/path", {"http", "", "", "host", 10100, "/path", "", "", "http://host:10100/path"});
+ checkURL("http://host:/path", {"http", "", "", "host", 0, "/path", "", "", "http://host/path"});
+ checkURL("http://host:123", {"http", "", "", "host", 123, "/", "", "", "http://host:123/"});
+ checkURL("http://host:", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
+ checkURL("http://hos\tt\n:\t1\n2\t3\t/\npath", {"http", "", "", "host", 123, "/path", "", "", "http://host:123/path"});
// 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.
@@ -372,6 +385,27 @@
checkRelativeURLDifferences("//", "https://www.webkit.org/path",
{"", "", "", "", 0, "", "", "", ""},
{"https", "", "", "", 0, "/", "", "", "https:/"});
+ checkURLDifferences("http://127.0.0.1:65536/path",
+ {"", "", "", "", 0, "", "", "", ""},
+ {"http", "", "", "127.0.0.1", 65535, "/path", "", "", "http://127.0.0.1:65536/path"});
+ checkURLDifferences("http://host:abc",
+ {"", "", "", "", 0, "", "", "", ""},
+ {"", "", "", "", 0, "", "", "", "http://host:abc"});
+ checkURLDifferences("http://host:65536",
+ {"", "", "", "", 0, "", "", "", ""},
+ {"http", "", "", "host", 65535, "/", "", "", "http://host:65536/"});
+ checkURLDifferences("http://127.0.0.1:abc",
+ {"", "", "", "", 0, "", "", "", ""},
+ {"", "", "", "", 0, "", "", "", "http://127.0.0.1:abc"});
+ checkURLDifferences("http://127.0.0.1:65536",
+ {"", "", "", "", 0, "", "", "", ""},
+ {"http", "", "", "127.0.0.1", 65535, "/", "", "", "http://127.0.0.1:65536/"});
+ checkURLDifferences("http://[0:f::f:f:0:0]:abc",
+ {"", "", "", "", 0, "", "", "", ""},
+ {"", "", "", "", 0, "", "", "", "http://[0:f::f:f:0:0]:abc"});
+ checkURLDifferences("http://[0:f::f:f:0:0]:65536",
+ {"", "", "", "", 0, "", "", "", ""},
+ {"http", "", "", "[0:f::f:f:0:0]", 65535, "/", "", "", "http://[0:f::f:f:0:0]:65536/"});
// This behavior matches Chrome and Firefox, but not WebKit using URL::parse.
// The behavior of URL::parse is clearly wrong because reparsing file://path would make path the host.
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes