Log Message
URLParser should not try to interpret host of URLs with unrecognized schemes as IPv4 address https://bugs.webkit.org/show_bug.cgi?id=164154
Reviewed by Andy Estes. Source/WebCore: This is needed to match behavior of all browsers. This is being discussed in the spec at https://github.com/whatwg/url/issues/148 Covered by new API tests. * platform/URLParser.cpp: (WebCore::URLParser::parseHostAndPort): Only try to parse and canonicalize the host as an IPv4 address if the scheme is special (http, wss, etc.) Tools: * TestWebKitAPI/Tests/WebCore/URLParser.cpp: (TestWebKitAPI::TEST_F):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (208085 => 208086)
--- trunk/Source/WebCore/ChangeLog 2016-10-29 00:14:37 UTC (rev 208085)
+++ trunk/Source/WebCore/ChangeLog 2016-10-29 00:17:01 UTC (rev 208086)
@@ -1,3 +1,19 @@
+2016-10-28 Alex Christensen <achristen...@webkit.org>
+
+ URLParser should not try to interpret host of URLs with unrecognized schemes as IPv4 address
+ https://bugs.webkit.org/show_bug.cgi?id=164154
+
+ Reviewed by Andy Estes.
+
+ This is needed to match behavior of all browsers.
+ This is being discussed in the spec at https://github.com/whatwg/url/issues/148
+
+ Covered by new API tests.
+
+ * platform/URLParser.cpp:
+ (WebCore::URLParser::parseHostAndPort):
+ Only try to parse and canonicalize the host as an IPv4 address if the scheme is special (http, wss, etc.)
+
2016-10-28 Chris Dumez <cdu...@apple.com>
DOMStringMap reports properties as non-enumerable
Modified: trunk/Source/WebCore/platform/URLParser.cpp (208085 => 208086)
--- trunk/Source/WebCore/platform/URLParser.cpp 2016-10-29 00:14:37 UTC (rev 208085)
+++ trunk/Source/WebCore/platform/URLParser.cpp 2016-10-29 00:17:01 UTC (rev 208086)
@@ -2572,25 +2572,28 @@
if (isInvalidDomainCharacter(*iterator))
return false;
}
- if (auto address = parseIPv4Host(CodePointIterator<CharacterType>(hostIterator, iterator))) {
- serializeIPv4(address.value());
- m_url.m_hostEnd = currentPosition(iterator);
- if (iterator.atEnd()) {
- m_url.m_portEnd = currentPosition(iterator);
- return true;
+ if (m_urlIsSpecial) {
+ if (auto address = parseIPv4Host(CodePointIterator<CharacterType>(hostIterator, iterator))) {
+ serializeIPv4(address.value());
+ m_url.m_hostEnd = currentPosition(iterator);
+ if (iterator.atEnd()) {
+ m_url.m_portEnd = currentPosition(iterator);
+ return true;
+ }
+ return parsePort(iterator);
}
- return parsePort(iterator);
}
for (; hostIterator != iterator; ++hostIterator) {
- if (LIKELY(!isTabOrNewline(*hostIterator))) {
- if (m_urlIsSpecial) {
- if (UNLIKELY(isASCIIUpper(*hostIterator)))
- syntaxViolation(hostIterator);
- appendToASCIIBuffer(toASCIILower(*hostIterator));
- } else
- appendToASCIIBuffer(*hostIterator);
+ if (UNLIKELY(isTabOrNewline(*hostIterator))) {
+ syntaxViolation(hostIterator);
+ continue;
+ }
+ if (m_urlIsSpecial) {
+ if (UNLIKELY(isASCIIUpper(*hostIterator)))
+ syntaxViolation(hostIterator);
+ appendToASCIIBuffer(toASCIILower(*hostIterator));
} else
- syntaxViolation(hostIterator);
+ appendToASCIIBuffer(*hostIterator);
}
m_url.m_hostEnd = currentPosition(iterator);
if (!hostIterator.atEnd())
Modified: trunk/Tools/ChangeLog (208085 => 208086)
--- trunk/Tools/ChangeLog 2016-10-29 00:14:37 UTC (rev 208085)
+++ trunk/Tools/ChangeLog 2016-10-29 00:17:01 UTC (rev 208086)
@@ -1,3 +1,13 @@
+2016-10-28 Alex Christensen <achristen...@webkit.org>
+
+ URLParser should not try to interpret host of URLs with unrecognized schemes as IPv4 address
+ https://bugs.webkit.org/show_bug.cgi?id=164154
+
+ Reviewed by Andy Estes.
+
+ * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+ (TestWebKitAPI::TEST_F):
+
2016-10-28 Sam Weinig <s...@webkit.org>
[WebIDL] Update parser and code generators to only access type information through the type property
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (208085 => 208086)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-10-29 00:14:37 UTC (rev 208085)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-10-29 00:17:01 UTC (rev 208086)
@@ -949,6 +949,14 @@
checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.256]",
{"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.256]"},
{"http", "", "", "[a:b:c:d:e:f::127.0.0.256]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.256]/"});
+ checkURLDifferences("http://123456", {"http", "", "", "0.1.226.64", 0, "/", "", "", "http://0.1.226.64/"}, {"http", "", "", "123456", 0, "/", "", "", "http://123456/"});
+ checkURL("asdf://123456", {"asdf", "", "", "123456", 0, "", "", "", "asdf://123456"});
+ checkURLDifferences("http://[0:0:0:0:a:b:c:d]",
+ {"http", "", "", "[::a:b:c:d]", 0, "/", "", "", "http://[::a:b:c:d]/"},
+ {"http", "", "", "[0:0:0:0:a:b:c:d]", 0, "/", "", "", "http://[0:0:0:0:a:b:c:d]/"});
+ checkURLDifferences("asdf://[0:0:0:0:a:b:c:d]",
+ {"asdf", "", "", "[::a:b:c:d]", 0, "", "", "", "asdf://[::a:b:c:d]"},
+ {"asdf", "", "", "[0:0:0:0:a:b:c:d]", 0, "", "", "", "asdf://[0:0:0:0:a:b:c:d]"});
}
TEST_F(URLParserTest, DefaultPort)
@@ -1105,6 +1113,7 @@
shouldFail("http://[a:b:c:d:e:f:127.0.0.0x11]"); // Chrome treats this as hex, Firefox and the spec fail
shouldFail("http://[a:b:c:d:e:f:127.0.-0.1]");
shouldFail("asdf://space InHost");
+ shouldFail("asdf://[0:0:0:0:a:b:c:d");
}
// 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