Title: [264282] trunk
- Revision
- 264282
- Author
- commit-qu...@webkit.org
- Date
- 2020-07-12 11:47:31 -0700 (Sun, 12 Jul 2020)
Log Message
Improve IPv6 detection when setting host/hostname
https://bugs.webkit.org/show_bug.cgi?id=214218
Patch by Rob Buis <rb...@igalia.com> on 2020-07-12
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Update improved test result.
* web-platform-tests/url/url-setters-expected.txt:
Source/WebCore:
Improve IPv6 detection when setting host/hostname by checking for '[' and ']' as
well as using reverse find for ':' separators, to ensure we are not finding a
separator within the IPv6 section of the url.
Behavior matches Chrome and Firefox.
Test: imported/w3c/web-platform-tests/url/url-setters.html
* html/URLDecomposition.cpp:
(WebCore::URLDecomposition::setHost):
Source/WTF:
* wtf/URL.cpp:
(WTF::URL::setHost): do not bail out if ':' was found but we start
with a '[', since the host may be IPv6.
(WTF::URL::setHostAndPort): multiple colons are acceptable only in case of IPv6.
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (264281 => 264282)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-07-12 18:08:08 UTC (rev 264281)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-07-12 18:47:31 UTC (rev 264282)
@@ -1,3 +1,14 @@
+2020-07-12 Rob Buis <rb...@igalia.com>
+
+ Improve IPv6 detection when setting host/hostname
+ https://bugs.webkit.org/show_bug.cgi?id=214218
+
+ Reviewed by Darin Adler.
+
+ Update improved test result.
+
+ * web-platform-tests/url/url-setters-expected.txt:
+
2020-07-10 Chris Dumez <cdu...@apple.com>
Resync web-platform-tests/streams from upstream
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt (264281 => 264282)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt 2020-07-12 18:08:08 UTC (rev 264281)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt 2020-07-12 18:47:31 UTC (rev 264282)
@@ -231,12 +231,12 @@
PASS URL: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized
PASS <a>: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized
PASS <area>: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized
-FAIL URL: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized assert_equals: expected "http://[::1]:2/" but got "http://example.net/"
-FAIL <a>: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized assert_equals: expected "http://[::1]:2/" but got "http://example.net/"
-FAIL <area>: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized assert_equals: expected "http://[::1]:2/" but got "http://example.net/"
-FAIL URL: Setting <http://example.net>.host = '[2001:db8::2]:4002' IPv6 literal address with port, crbug.com/1012416 assert_equals: expected "http://[2001:db8::2]:4002/" but got "http://example.net/"
-FAIL <a>: Setting <http://example.net>.host = '[2001:db8::2]:4002' IPv6 literal address with port, crbug.com/1012416 assert_equals: expected "http://[2001:db8::2]:4002/" but got "http://example.net/"
-FAIL <area>: Setting <http://example.net>.host = '[2001:db8::2]:4002' IPv6 literal address with port, crbug.com/1012416 assert_equals: expected "http://[2001:db8::2]:4002/" but got "http://example.net/"
+PASS URL: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized
+PASS <a>: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized
+PASS <area>: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized
+PASS URL: Setting <http://example.net>.host = '[2001:db8::2]:4002' IPv6 literal address with port, crbug.com/1012416
+PASS <a>: Setting <http://example.net>.host = '[2001:db8::2]:4002' IPv6 literal address with port, crbug.com/1012416
+PASS <area>: Setting <http://example.net>.host = '[2001:db8::2]:4002' IPv6 literal address with port, crbug.com/1012416
PASS URL: Setting <http://example.net>.host = 'example.com:80' Default port number is removed
PASS <a>: Setting <http://example.net>.host = 'example.com:80' Default port number is removed
PASS <area>: Setting <http://example.net>.host = 'example.com:80' Default port number is removed
@@ -372,9 +372,9 @@
PASS URL: Setting <http://example.net:8080>.hostname = '0x7F000001' IPv4 address syntax is normalized
PASS <a>: Setting <http://example.net:8080>.hostname = '0x7F000001' IPv4 address syntax is normalized
PASS <area>: Setting <http://example.net:8080>.hostname = '0x7F000001' IPv4 address syntax is normalized
-FAIL URL: Setting <http://example.net>.hostname = '[::0:01]' IPv6 address syntax is normalized assert_equals: expected "http://[::1]/" but got "http://example.net/"
-FAIL <a>: Setting <http://example.net>.hostname = '[::0:01]' IPv6 address syntax is normalized assert_equals: expected "http://[::1]/" but got "http://example.net/"
-FAIL <area>: Setting <http://example.net>.hostname = '[::0:01]' IPv6 address syntax is normalized assert_equals: expected "http://[::1]/" but got "http://example.net/"
+PASS URL: Setting <http://example.net>.hostname = '[::0:01]' IPv6 address syntax is normalized
+PASS <a>: Setting <http://example.net>.hostname = '[::0:01]' IPv6 address syntax is normalized
+PASS <area>: Setting <http://example.net>.hostname = '[::0:01]' IPv6 address syntax is normalized
FAIL URL: Setting <http://example.net/path>.hostname = 'example.com:8080' Stuff after a : delimiter is ignored assert_equals: expected "http://example.com/path" but got "http://example.net/path"
FAIL <a>: Setting <http://example.net/path>.hostname = 'example.com:8080' Stuff after a : delimiter is ignored assert_equals: expected "http://example.com/path" but got "http://example.net/path"
FAIL <area>: Setting <http://example.net/path>.hostname = 'example.com:8080' Stuff after a : delimiter is ignored assert_equals: expected "http://example.com/path" but got "http://example.net/path"
Modified: trunk/Source/WTF/ChangeLog (264281 => 264282)
--- trunk/Source/WTF/ChangeLog 2020-07-12 18:08:08 UTC (rev 264281)
+++ trunk/Source/WTF/ChangeLog 2020-07-12 18:47:31 UTC (rev 264282)
@@ -1,3 +1,15 @@
+2020-07-12 Rob Buis <rb...@igalia.com>
+
+ Improve IPv6 detection when setting host/hostname
+ https://bugs.webkit.org/show_bug.cgi?id=214218
+
+ Reviewed by Darin Adler.
+
+ * wtf/URL.cpp:
+ (WTF::URL::setHost): do not bail out if ':' was found but we start
+ with a '[', since the host may be IPv6.
+ (WTF::URL::setHostAndPort): multiple colons are acceptable only in case of IPv6.
+
2020-07-11 Sam Weinig <wei...@apple.com> and Yusuke Suzuki <ysuz...@apple.com>
Relanding "Make hasher work with tuple-like classes"
Modified: trunk/Source/WTF/wtf/URL.cpp (264281 => 264282)
--- trunk/Source/WTF/wtf/URL.cpp 2020-07-12 18:08:08 UTC (rev 264281)
+++ trunk/Source/WTF/wtf/URL.cpp 2020-07-12 18:47:31 UTC (rev 264282)
@@ -415,7 +415,7 @@
if (!m_isValid)
return;
- if (newHost.contains(':'))
+ if (newHost.contains(':') && !newHost.startsWith('['))
return;
Vector<UChar, 512> encodedHostName;
@@ -456,10 +456,13 @@
auto hostName = hostAndPort;
StringView portString;
- auto colonIndex = hostName.find(':');
+ auto colonIndex = hostName.reverseFind(':');
if (colonIndex != notFound) {
portString = hostName.substring(colonIndex + 1);
hostName = hostName.substring(0, colonIndex);
+ // Multiple colons are acceptable only in case of IPv6.
+ if (hostName.contains(':') && !hostName.startsWith('['))
+ return;
if (!parseUInt16(portString))
portString = { };
}
Modified: trunk/Source/WebCore/ChangeLog (264281 => 264282)
--- trunk/Source/WebCore/ChangeLog 2020-07-12 18:08:08 UTC (rev 264281)
+++ trunk/Source/WebCore/ChangeLog 2020-07-12 18:47:31 UTC (rev 264282)
@@ -1,3 +1,21 @@
+2020-07-12 Rob Buis <rb...@igalia.com>
+
+ Improve IPv6 detection when setting host/hostname
+ https://bugs.webkit.org/show_bug.cgi?id=214218
+
+ Reviewed by Darin Adler.
+
+ Improve IPv6 detection when setting host/hostname by checking for '[' and ']' as
+ well as using reverse find for ':' separators, to ensure we are not finding a
+ separator within the IPv6 section of the url.
+
+ Behavior matches Chrome and Firefox.
+
+ Test: imported/w3c/web-platform-tests/url/url-setters.html
+
+ * html/URLDecomposition.cpp:
+ (WebCore::URLDecomposition::setHost):
+
2020-07-12 Zalan Bujtas <za...@apple.com>
[LFC][BFC][Min-Max width] Regular block level box resets the horizontal stacking
Modified: trunk/Source/WebCore/html/URLDecomposition.cpp (264281 => 264282)
--- trunk/Source/WebCore/html/URLDecomposition.cpp 2020-07-12 18:08:08 UTC (rev 264281)
+++ trunk/Source/WebCore/html/URLDecomposition.cpp 2020-07-12 18:47:31 UTC (rev 264282)
@@ -99,7 +99,7 @@
if (value.isEmpty() && !fullURL.protocolIs("file"))
return;
- size_t separator = value.find(':');
+ size_t separator = value.reverseFind(':');
if (!separator)
return;
@@ -106,9 +106,14 @@
if (fullURL.cannotBeABaseURL() || !fullURL.canSetHostOrPort())
return;
- if (separator == notFound)
+ // No port if no colon or rightmost colon is within the IPv6 section.
+ size_t ipv6Separator = value.reverseFind(']');
+ if (separator == notFound || (ipv6Separator != notFound && ipv6Separator > separator))
fullURL.setHost(value);
else {
+ // Multiple colons are acceptable only in case of IPv6.
+ if (value.find(':') != separator && ipv6Separator == notFound)
+ return;
unsigned portLength = countASCIIDigits(value.substring(separator + 1));
if (!portLength) {
// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes