Title: [281963] trunk
Revision
281963
Author
[email protected]
Date
2021-09-02 16:10:11 -0700 (Thu, 02 Sep 2021)

Log Message

Reject non-IPv4 hostnames that end in numbers
https://bugs.webkit.org/show_bug.cgi?id=228826

Patch by Alex Christensen <[email protected]> on 2021-09-02
Reviewed by Tim Horton.

LayoutTests/imported/w3c:

* web-platform-tests/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt:
This test has its expectations change because, in our test infrastructure, it loads a url with host "www1.127.0.0.1" which this change now rejects.
When run from wpt.fyi this is not the case.
* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-origin-expected.txt:
* web-platform-tests/url/a-element-origin-xhtml-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/failure-expected.txt:
* web-platform-tests/url/resources/urltestdata.json:
* web-platform-tests/url/url-constructor.any-expected.txt:
* web-platform-tests/url/url-constructor.any.worker-expected.txt:
* web-platform-tests/url/url-origin.any-expected.txt:
* web-platform-tests/url/url-origin.any.worker-expected.txt:

Source/WTF:

This implements a recent change to the URL specification at https://github.com/whatwg/url/pull/619
Chrome has made the same change in https://crbug.com/1237032

Since there are no TLDs that are only numbers and some think it might be confusing to have a valid URL
like http://example.com.127.0.0.1/ we prevent URLs that end in a segment between dots that contains only
numbers from parsing successfully.

* wtf/URLParser.cpp:
(WTF::URLParser::parse):
(WTF::dnsNameEndsInNumber):
(WTF::URLParser::parseHostAndPort):
I give more information in the return type so one can tell what the code is doing.
We only check if it is valid or not, but for documentation purposes I think it's useful to return more information.
* wtf/URLParser.h:

Tools:

* TestWebKitAPI/Tests/WTF/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update expectations for a few strange URLs that are no longer valid.

LayoutTests:

* fast/url/ipv4-expected.txt:
* fast/url/ipv4.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (281962 => 281963)


--- trunk/LayoutTests/ChangeLog	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/ChangeLog	2021-09-02 23:10:11 UTC (rev 281963)
@@ -1,3 +1,13 @@
+2021-09-02  Alex Christensen  <[email protected]>
+
+        Reject non-IPv4 hostnames that end in numbers
+        https://bugs.webkit.org/show_bug.cgi?id=228826
+
+        Reviewed by Tim Horton.
+
+        * fast/url/ipv4-expected.txt:
+        * fast/url/ipv4.html:
+
 2021-09-02  Eric Hutchison  <[email protected]>
 
         [BigSur Release wk2] webgl/2.0.0/conformance2/textures/video/tex-2d-r8ui-red_integer-unsigned_byte.html is a flaky timeout.

Modified: trunk/LayoutTests/fast/url/ipv4-expected.txt (281962 => 281963)


--- trunk/LayoutTests/fast/url/ipv4-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/fast/url/ipv4-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -10,7 +10,7 @@
 PASS canonicalize('http://192.168.9.com/') is 'http://192.168.9.com/'
 PASS canonicalize('http://19a.168.0.1/') is 'http://19a.168.0.1/'
 PASS canonicalize('http://0308.0250.00.01/') is 'http://0308.0250.00.01/'
-PASS canonicalize('http://0xCG.0xA8.0x0.0x1/') is 'http://0xcg.0xa8.0x0.0x1/'
+PASS canonicalize('http://0xCG.0xA8.0x0.0x1/') is 'http://0xCG.0xA8.0x0.0x1/'
 PASS canonicalize('http://192/') is 'http://0.0.0.192/'
 PASS canonicalize('http://0xC0a80001/') is 'http://192.168.0.1/'
 PASS canonicalize('http://030052000001/') is 'http://192.168.0.1/'
@@ -50,7 +50,7 @@
 PASS canonicalize('http://276.1.2/') is 'http://276.1.2/'
 PASS canonicalize('http://192.168.0.1 hello/') is 'http://192.168.0.1 hello/'
 PASS canonicalize('http://0000000000000300.0x00000000000000fF.00000000000000001/') is 'http://192.255.0.1/'
-PASS canonicalize('http://0000000000000300.0xffffffffFFFFFFFF.3022415481470977/') is 'http://0000000000000300.0xffffffffffffffff.3022415481470977/'
+PASS canonicalize('http://0000000000000300.0xffffffffFFFFFFFF.3022415481470977/') is 'http://0000000000000300.0xffffffffFFFFFFFF.3022415481470977/'
 PASS canonicalize('http://00000000000000000001/') is 'http://0.0.0.1/'
 PASS canonicalize('http://0000000000000000100000000000000001/') is 'http://0000000000000000100000000000000001/'
 PASS canonicalize('http://0.0.0.000000000000000000z/') is 'http://0.0.0.000000000000000000z/'

Modified: trunk/LayoutTests/fast/url/ipv4.html (281962 => 281963)


--- trunk/LayoutTests/fast/url/ipv4.html	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/fast/url/ipv4.html	2021-09-02 23:10:11 UTC (rev 281963)
@@ -22,7 +22,7 @@
   // Invalid characters for the base should be rejected.
   ["19a.168.0.1", ""],
   ["0308.0250.00.01", ""],
-  ["0xCG.0xA8.0x0.0x1", ""],
+  ["0xCG.0xA8.0x0.0x1", "0xCG.0xA8.0x0.0x1"],
 
   // If there are not enough components, the last one should fill them out.
   ["192", "0.0.0.192"],
@@ -80,7 +80,7 @@
 
   // Very large numbers.
   ["0000000000000300.0x00000000000000fF.00000000000000001", "192.255.0.1"],
-  ["0000000000000300.0xffffffffFFFFFFFF.3022415481470977", ""],
+  ["0000000000000300.0xffffffffFFFFFFFF.3022415481470977", "0000000000000300.0xffffffffFFFFFFFF.3022415481470977"],
 
   // A number has no length limit, but long numbers can still overflow.
   ["00000000000000000001", "0.0.0.1"],

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-02 23:10:11 UTC (rev 281963)
@@ -1,3 +1,24 @@
+2021-09-02  Alex Christensen  <[email protected]>
+
+        Reject non-IPv4 hostnames that end in numbers
+        https://bugs.webkit.org/show_bug.cgi?id=228826
+
+        Reviewed by Tim Horton.
+
+        * web-platform-tests/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt:
+        This test has its expectations change because, in our test infrastructure, it loads a url with host "www1.127.0.0.1" which this change now rejects.
+        When run from wpt.fyi this is not the case.
+        * web-platform-tests/url/a-element-expected.txt:
+        * web-platform-tests/url/a-element-origin-expected.txt:
+        * web-platform-tests/url/a-element-origin-xhtml-expected.txt:
+        * web-platform-tests/url/a-element-xhtml-expected.txt:
+        * web-platform-tests/url/failure-expected.txt:
+        * web-platform-tests/url/resources/urltestdata.json:
+        * web-platform-tests/url/url-constructor.any-expected.txt:
+        * web-platform-tests/url/url-constructor.any.worker-expected.txt:
+        * web-platform-tests/url/url-origin.any-expected.txt:
+        * web-platform-tests/url/url-origin.any.worker-expected.txt:
+
 2021-09-02  Myles C. Maxfield  <[email protected]>
 
         FontFaceSet.add() needs to throw when called on a CSS-connected font

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -1,10 +1,4 @@
-Blocked access to external URL http://www1.127.0.0.1:8800/html/infrastructure/safe-passing-of-structured-data/resources/echo-iframe.html
-Blocked access to external URL http://www1.127.0.0.1:8800/html/infrastructure/safe-passing-of-structured-data/resources/echo-iframe.html
-Blocked access to external URL http://www1.127.0.0.1:8800/html/infrastructure/safe-passing-of-structured-data/resources/echo-iframe.html
-Blocked access to external URL http://www1.127.0.0.1:8800/html/infrastructure/safe-passing-of-structured-data/resources/echo-iframe.html
 
-Harness Error (TIMEOUT), message = null
-
 FAIL page-created Error (worker) The object can not be cloned.
 FAIL page-created Error (cross-site iframe) The object can not be cloned.
 PASS page-created DOMException (worker)
@@ -14,5 +8,5 @@
 FAIL web API-created TypeError (worker) The object can not be cloned.
 FAIL web API-created TypeError (cross-site iframe) The object can not be cloned.
 FAIL web API-created DOMException (worker) assert_equals: expected (string) "createElement@[native code]\n@http://localhost:8800/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:27\n@http://localhost:8800/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:41:31\n@http://localhost:8800/resources/testharness.js:2087:30\nasync_test@http://localhost:8800/resources/testharness.js:594:38\nstackTests@http://localhost:8800/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:40:13\nglobal code@http://localhost:8800/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:11" but got (undefined) undefined
-TIMEOUT web API-created DOMException (cross-site iframe) Test timed out
+FAIL web API-created DOMException (cross-site iframe) assert_equals: expected (string) "createElement@[native code]\n@http://localhost:8800/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:27\n@http://localhost:8800/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:60:31\n@http://localhost:8800/resources/testharness.js:2087:30\nasync_test@http://localhost:8800/resources/testharness.js:594:38\nstackTests@http://localhost:8800/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:57:13\nglobal code@http://localhost:8800/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:11" but got (undefined) undefined
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -297,7 +297,6 @@
 PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
 PASS Parsing: <http://./> against <about:blank>
 PASS Parsing: <http://../> against <about:blank>
-PASS Parsing: <http://0..0x300/> against <about:blank>
 PASS Parsing: <http://[www.google.com]/> against <about:blank>
 PASS Parsing: <http://[google.com]> against <http://other.com/>
 PASS Parsing: <http://[::1.2.3.4x]> against <http://other.com/>
@@ -421,11 +420,15 @@
 PASS Parsing: <http://foo.bar/baz?qux#foo<bar> against <about:blank>
 PASS Parsing: <http://foo.bar/baz?qux#foo>bar> against <about:blank>
 PASS Parsing: <http://foo.bar/baz?qux#foo`bar> against <about:blank>
+PASS Parsing: <http://1.2.3.4/> against <http://other.com/>
+PASS Parsing: <http://1.2.3.4./> against <http://other.com/>
 PASS Parsing: <http://192.168.257> against <http://other.com/>
+PASS Parsing: <http://192.168.257.> against <http://other.com/>
 PASS Parsing: <http://192.168.257.com> against <http://other.com/>
 PASS Parsing: <http://256> against <http://other.com/>
 PASS Parsing: <http://256.com> against <http://other.com/>
 PASS Parsing: <http://999999999> against <http://other.com/>
+PASS Parsing: <http://999999999.> against <http://other.com/>
 PASS Parsing: <http://999999999.com> against <http://other.com/>
 PASS Parsing: <http://10000000000> against <http://other.com/>
 PASS Parsing: <http://10000000000.com> against <http://other.com/>
@@ -434,7 +437,6 @@
 PASS Parsing: <http://0xffffffff> against <http://other.com/>
 PASS Parsing: <http://0xffffffff1> against <http://other.com/>
 PASS Parsing: <http://256.256.256.256> against <http://other.com/>
-PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
 PASS Parsing: <https://0x.0x.0> against <about:blank>
 PASS Parsing: <https://0x100000000/test> against <about:blank>
 PASS Parsing: <https://256.0.0.1/test> against <about:blank>
@@ -589,7 +591,6 @@
 PASS Parsing: <non-special://[:80/> against <about:blank>
 PASS Parsing: <blob:https://example.com:443/> against <about:blank>
 PASS Parsing: <blob:d3958f5c-0777-0845-9dcf-2cb28783acaf> against <about:blank>
-PASS Parsing: <http://0177.0.0.0189> against <about:blank>
 PASS Parsing: <http://0x7f.0.0.0x7g> against <about:blank>
 PASS Parsing: <http://0X7F.0.0.0X7G> against <about:blank>
 PASS Parsing: <http://[::127.0.0.0.1]> against <about:blank>
@@ -644,4 +645,34 @@
 PASS Parsing: <abc:rootless> against <abc:/path>
 PASS Parsing: <abc:rootless> against <abc:path>
 PASS Parsing: <abc:/rooted> against <abc://host/path>
+PASS Parsing: <http://1.2.3.4.5> against <http://other.com/>
+PASS Parsing: <http://1.2.3.4.5.> against <http://other.com/>
+PASS Parsing: <http://0..0x300/> against <about:blank>
+PASS Parsing: <http://0..0x300./> against <about:blank>
+PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256.256.> against <http://other.com/>
+PASS Parsing: <http://1.2.3.08> against <about:blank>
+PASS Parsing: <http://1.2.3.08.> against <about:blank>
+PASS Parsing: <http://1.2.3.09> against <about:blank>
+PASS Parsing: <http://09.2.3.4> against <about:blank>
+PASS Parsing: <http://09.2.3.4.> against <about:blank>
+PASS Parsing: <http://01.2.3.4.5> against <about:blank>
+PASS Parsing: <http://01.2.3.4.5.> against <about:blank>
+PASS Parsing: <http://0x100.2.3.4> against <about:blank>
+PASS Parsing: <http://0x100.2.3.4.> against <about:blank>
+PASS Parsing: <http://0x1.2.3.4.5> against <about:blank>
+PASS Parsing: <http://0x1.2.3.4.5.> against <about:blank>
+PASS Parsing: <http://foo.1.2.3.4> against <about:blank>
+PASS Parsing: <http://foo.1.2.3.4.> against <about:blank>
+PASS Parsing: <http://foo.2.3.4> against <about:blank>
+PASS Parsing: <http://foo.2.3.4.> against <about:blank>
+PASS Parsing: <http://foo.09> against <about:blank>
+PASS Parsing: <http://foo.09.> against <about:blank>
+PASS Parsing: <http://foo.0x4> against <about:blank>
+PASS Parsing: <http://foo.0x4.> against <about:blank>
+PASS Parsing: <http://foo.09..> against <about:blank>
+PASS Parsing: <http://0999999999999999999/> against <about:blank>
+PASS Parsing: <http://foo.0x> against <about:blank>
+PASS Parsing: <http://foo.0XFfFfFfFfFfFfFfFfFfAcE123> against <about:blank>
+PASS Parsing: <http://💩.123/> against <about:blank>
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -221,7 +221,6 @@
 PASS Parsing origin: <http://0Xc0.0250.01> against <http://other.com/>
 PASS Parsing origin: <http://./> against <about:blank>
 PASS Parsing origin: <http://../> against <about:blank>
-PASS Parsing origin: <http://0..0x300/> against <about:blank>
 PASS Parsing origin: <http://foo:💩@example.com/bar> against <http://other.com/>
 PASS Parsing origin: <#> against <test:test>
 PASS Parsing origin: <#x> against <mailto:[email protected]>
@@ -288,16 +287,19 @@
 PASS Parsing origin: <http://foo.bar/baz?qux#foo<bar> against <about:blank>
 PASS Parsing origin: <http://foo.bar/baz?qux#foo>bar> against <about:blank>
 PASS Parsing origin: <http://foo.bar/baz?qux#foo`bar> against <about:blank>
+PASS Parsing origin: <http://1.2.3.4/> against <http://other.com/>
+PASS Parsing origin: <http://1.2.3.4./> against <http://other.com/>
 PASS Parsing origin: <http://192.168.257> against <http://other.com/>
+PASS Parsing origin: <http://192.168.257.> against <http://other.com/>
 PASS Parsing origin: <http://192.168.257.com> against <http://other.com/>
 PASS Parsing origin: <http://256> against <http://other.com/>
 PASS Parsing origin: <http://256.com> against <http://other.com/>
 PASS Parsing origin: <http://999999999> against <http://other.com/>
+PASS Parsing origin: <http://999999999.> against <http://other.com/>
 PASS Parsing origin: <http://999999999.com> against <http://other.com/>
 PASS Parsing origin: <http://10000000000.com> against <http://other.com/>
 PASS Parsing origin: <http://4294967295> against <http://other.com/>
 PASS Parsing origin: <http://0xffffffff> against <http://other.com/>
-PASS Parsing origin: <http://256.256.256.256.256> against <http://other.com/>
 PASS Parsing origin: <https://0x.0x.0> against <about:blank>
 PASS Parsing origin: <asdf://%43%7C/> against <about:blank>
 PASS Parsing origin: <http://[1:0::]> against <http://example.net/>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-xhtml-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-xhtml-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-xhtml-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -221,7 +221,6 @@
 PASS Parsing origin: <http://0Xc0.0250.01> against <http://other.com/>
 PASS Parsing origin: <http://./> against <about:blank>
 PASS Parsing origin: <http://../> against <about:blank>
-PASS Parsing origin: <http://0..0x300/> against <about:blank>
 PASS Parsing origin: <http://foo:💩@example.com/bar> against <http://other.com/>
 PASS Parsing origin: <#> against <test:test>
 PASS Parsing origin: <#x> against <mailto:[email protected]>
@@ -288,16 +287,19 @@
 PASS Parsing origin: <http://foo.bar/baz?qux#foo<bar> against <about:blank>
 PASS Parsing origin: <http://foo.bar/baz?qux#foo>bar> against <about:blank>
 PASS Parsing origin: <http://foo.bar/baz?qux#foo`bar> against <about:blank>
+PASS Parsing origin: <http://1.2.3.4/> against <http://other.com/>
+PASS Parsing origin: <http://1.2.3.4./> against <http://other.com/>
 PASS Parsing origin: <http://192.168.257> against <http://other.com/>
+PASS Parsing origin: <http://192.168.257.> against <http://other.com/>
 PASS Parsing origin: <http://192.168.257.com> against <http://other.com/>
 PASS Parsing origin: <http://256> against <http://other.com/>
 PASS Parsing origin: <http://256.com> against <http://other.com/>
 PASS Parsing origin: <http://999999999> against <http://other.com/>
+PASS Parsing origin: <http://999999999.> against <http://other.com/>
 PASS Parsing origin: <http://999999999.com> against <http://other.com/>
 PASS Parsing origin: <http://10000000000.com> against <http://other.com/>
 PASS Parsing origin: <http://4294967295> against <http://other.com/>
 PASS Parsing origin: <http://0xffffffff> against <http://other.com/>
-PASS Parsing origin: <http://256.256.256.256.256> against <http://other.com/>
 PASS Parsing origin: <https://0x.0x.0> against <about:blank>
 PASS Parsing origin: <asdf://%43%7C/> against <about:blank>
 PASS Parsing origin: <http://[1:0::]> against <http://example.net/>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -297,7 +297,6 @@
 PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
 PASS Parsing: <http://./> against <about:blank>
 PASS Parsing: <http://../> against <about:blank>
-PASS Parsing: <http://0..0x300/> against <about:blank>
 PASS Parsing: <http://[www.google.com]/> against <about:blank>
 PASS Parsing: <http://[google.com]> against <http://other.com/>
 PASS Parsing: <http://[::1.2.3.4x]> against <http://other.com/>
@@ -421,11 +420,15 @@
 PASS Parsing: <http://foo.bar/baz?qux#foo<bar> against <about:blank>
 PASS Parsing: <http://foo.bar/baz?qux#foo>bar> against <about:blank>
 PASS Parsing: <http://foo.bar/baz?qux#foo`bar> against <about:blank>
+PASS Parsing: <http://1.2.3.4/> against <http://other.com/>
+PASS Parsing: <http://1.2.3.4./> against <http://other.com/>
 PASS Parsing: <http://192.168.257> against <http://other.com/>
+PASS Parsing: <http://192.168.257.> against <http://other.com/>
 PASS Parsing: <http://192.168.257.com> against <http://other.com/>
 PASS Parsing: <http://256> against <http://other.com/>
 PASS Parsing: <http://256.com> against <http://other.com/>
 PASS Parsing: <http://999999999> against <http://other.com/>
+PASS Parsing: <http://999999999.> against <http://other.com/>
 PASS Parsing: <http://999999999.com> against <http://other.com/>
 PASS Parsing: <http://10000000000> against <http://other.com/>
 PASS Parsing: <http://10000000000.com> against <http://other.com/>
@@ -434,7 +437,6 @@
 PASS Parsing: <http://0xffffffff> against <http://other.com/>
 PASS Parsing: <http://0xffffffff1> against <http://other.com/>
 PASS Parsing: <http://256.256.256.256> against <http://other.com/>
-PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
 PASS Parsing: <https://0x.0x.0> against <about:blank>
 PASS Parsing: <https://0x100000000/test> against <about:blank>
 PASS Parsing: <https://256.0.0.1/test> against <about:blank>
@@ -589,7 +591,6 @@
 PASS Parsing: <non-special://[:80/> against <about:blank>
 PASS Parsing: <blob:https://example.com:443/> against <about:blank>
 PASS Parsing: <blob:d3958f5c-0777-0845-9dcf-2cb28783acaf> against <about:blank>
-PASS Parsing: <http://0177.0.0.0189> against <about:blank>
 PASS Parsing: <http://0x7f.0.0.0x7g> against <about:blank>
 PASS Parsing: <http://0X7F.0.0.0X7G> against <about:blank>
 PASS Parsing: <http://[::127.0.0.0.1]> against <about:blank>
@@ -644,4 +645,34 @@
 PASS Parsing: <abc:rootless> against <abc:/path>
 PASS Parsing: <abc:rootless> against <abc:path>
 PASS Parsing: <abc:/rooted> against <abc://host/path>
+PASS Parsing: <http://1.2.3.4.5> against <http://other.com/>
+PASS Parsing: <http://1.2.3.4.5.> against <http://other.com/>
+PASS Parsing: <http://0..0x300/> against <about:blank>
+PASS Parsing: <http://0..0x300./> against <about:blank>
+PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256.256.> against <http://other.com/>
+PASS Parsing: <http://1.2.3.08> against <about:blank>
+PASS Parsing: <http://1.2.3.08.> against <about:blank>
+PASS Parsing: <http://1.2.3.09> against <about:blank>
+PASS Parsing: <http://09.2.3.4> against <about:blank>
+PASS Parsing: <http://09.2.3.4.> against <about:blank>
+PASS Parsing: <http://01.2.3.4.5> against <about:blank>
+PASS Parsing: <http://01.2.3.4.5.> against <about:blank>
+PASS Parsing: <http://0x100.2.3.4> against <about:blank>
+PASS Parsing: <http://0x100.2.3.4.> against <about:blank>
+PASS Parsing: <http://0x1.2.3.4.5> against <about:blank>
+PASS Parsing: <http://0x1.2.3.4.5.> against <about:blank>
+PASS Parsing: <http://foo.1.2.3.4> against <about:blank>
+PASS Parsing: <http://foo.1.2.3.4.> against <about:blank>
+PASS Parsing: <http://foo.2.3.4> against <about:blank>
+PASS Parsing: <http://foo.2.3.4.> against <about:blank>
+PASS Parsing: <http://foo.09> against <about:blank>
+PASS Parsing: <http://foo.09.> against <about:blank>
+PASS Parsing: <http://foo.0x4> against <about:blank>
+PASS Parsing: <http://foo.0x4.> against <about:blank>
+PASS Parsing: <http://foo.09..> against <about:blank>
+PASS Parsing: <http://0999999999999999999/> against <about:blank>
+PASS Parsing: <http://foo.0x> against <about:blank>
+PASS Parsing: <http://foo.0XFfFfFfFfFfFfFfFfFfAcE123> against <about:blank>
+PASS Parsing: <http://💩.123/> against <about:blank>
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/failure-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/failure-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/failure-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -484,4 +484,154 @@
 PASS sendBeacon(): file://xn--/p should throw
 PASS Location's href: file://xn--/p should throw
 PASS window.open(): file://xn--/p should throw
+PASS URL's constructor's base argument: http://0..0x300/ should throw
+PASS URL's href: http://0..0x300/ should throw
+PASS XHR: http://0..0x300/ should throw
+PASS sendBeacon(): http://0..0x300/ should throw
+PASS Location's href: http://0..0x300/ should throw
+PASS window.open(): http://0..0x300/ should throw
+PASS URL's constructor's base argument: http://0..0x300./ should throw
+PASS URL's href: http://0..0x300./ should throw
+PASS XHR: http://0..0x300./ should throw
+PASS sendBeacon(): http://0..0x300./ should throw
+PASS Location's href: http://0..0x300./ should throw
+PASS window.open(): http://0..0x300./ should throw
+PASS URL's constructor's base argument: http://1.2.3.08 should throw
+PASS URL's href: http://1.2.3.08 should throw
+PASS XHR: http://1.2.3.08 should throw
+PASS sendBeacon(): http://1.2.3.08 should throw
+PASS Location's href: http://1.2.3.08 should throw
+PASS window.open(): http://1.2.3.08 should throw
+PASS URL's constructor's base argument: http://1.2.3.08. should throw
+PASS URL's href: http://1.2.3.08. should throw
+PASS XHR: http://1.2.3.08. should throw
+PASS sendBeacon(): http://1.2.3.08. should throw
+PASS Location's href: http://1.2.3.08. should throw
+PASS window.open(): http://1.2.3.08. should throw
+PASS URL's constructor's base argument: http://1.2.3.09 should throw
+PASS URL's href: http://1.2.3.09 should throw
+PASS XHR: http://1.2.3.09 should throw
+PASS sendBeacon(): http://1.2.3.09 should throw
+PASS Location's href: http://1.2.3.09 should throw
+PASS window.open(): http://1.2.3.09 should throw
+PASS URL's constructor's base argument: http://09.2.3.4 should throw
+PASS URL's href: http://09.2.3.4 should throw
+PASS XHR: http://09.2.3.4 should throw
+PASS sendBeacon(): http://09.2.3.4 should throw
+PASS Location's href: http://09.2.3.4 should throw
+PASS window.open(): http://09.2.3.4 should throw
+PASS URL's constructor's base argument: http://09.2.3.4. should throw
+PASS URL's href: http://09.2.3.4. should throw
+PASS XHR: http://09.2.3.4. should throw
+PASS sendBeacon(): http://09.2.3.4. should throw
+PASS Location's href: http://09.2.3.4. should throw
+PASS window.open(): http://09.2.3.4. should throw
+PASS URL's constructor's base argument: http://01.2.3.4.5 should throw
+PASS URL's href: http://01.2.3.4.5 should throw
+PASS XHR: http://01.2.3.4.5 should throw
+PASS sendBeacon(): http://01.2.3.4.5 should throw
+PASS Location's href: http://01.2.3.4.5 should throw
+PASS window.open(): http://01.2.3.4.5 should throw
+PASS URL's constructor's base argument: http://01.2.3.4.5. should throw
+PASS URL's href: http://01.2.3.4.5. should throw
+PASS XHR: http://01.2.3.4.5. should throw
+PASS sendBeacon(): http://01.2.3.4.5. should throw
+PASS Location's href: http://01.2.3.4.5. should throw
+PASS window.open(): http://01.2.3.4.5. should throw
+PASS URL's constructor's base argument: http://0x100.2.3.4 should throw
+PASS URL's href: http://0x100.2.3.4 should throw
+PASS XHR: http://0x100.2.3.4 should throw
+PASS sendBeacon(): http://0x100.2.3.4 should throw
+PASS Location's href: http://0x100.2.3.4 should throw
+PASS window.open(): http://0x100.2.3.4 should throw
+PASS URL's constructor's base argument: http://0x100.2.3.4. should throw
+PASS URL's href: http://0x100.2.3.4. should throw
+PASS XHR: http://0x100.2.3.4. should throw
+PASS sendBeacon(): http://0x100.2.3.4. should throw
+PASS Location's href: http://0x100.2.3.4. should throw
+PASS window.open(): http://0x100.2.3.4. should throw
+PASS URL's constructor's base argument: http://0x1.2.3.4.5 should throw
+PASS URL's href: http://0x1.2.3.4.5 should throw
+PASS XHR: http://0x1.2.3.4.5 should throw
+PASS sendBeacon(): http://0x1.2.3.4.5 should throw
+PASS Location's href: http://0x1.2.3.4.5 should throw
+PASS window.open(): http://0x1.2.3.4.5 should throw
+PASS URL's constructor's base argument: http://0x1.2.3.4.5. should throw
+PASS URL's href: http://0x1.2.3.4.5. should throw
+PASS XHR: http://0x1.2.3.4.5. should throw
+PASS sendBeacon(): http://0x1.2.3.4.5. should throw
+PASS Location's href: http://0x1.2.3.4.5. should throw
+PASS window.open(): http://0x1.2.3.4.5. should throw
+PASS URL's constructor's base argument: http://foo.1.2.3.4 should throw
+PASS URL's href: http://foo.1.2.3.4 should throw
+PASS XHR: http://foo.1.2.3.4 should throw
+PASS sendBeacon(): http://foo.1.2.3.4 should throw
+PASS Location's href: http://foo.1.2.3.4 should throw
+PASS window.open(): http://foo.1.2.3.4 should throw
+PASS URL's constructor's base argument: http://foo.1.2.3.4. should throw
+PASS URL's href: http://foo.1.2.3.4. should throw
+PASS XHR: http://foo.1.2.3.4. should throw
+PASS sendBeacon(): http://foo.1.2.3.4. should throw
+PASS Location's href: http://foo.1.2.3.4. should throw
+PASS window.open(): http://foo.1.2.3.4. should throw
+PASS URL's constructor's base argument: http://foo.2.3.4 should throw
+PASS URL's href: http://foo.2.3.4 should throw
+PASS XHR: http://foo.2.3.4 should throw
+PASS sendBeacon(): http://foo.2.3.4 should throw
+PASS Location's href: http://foo.2.3.4 should throw
+PASS window.open(): http://foo.2.3.4 should throw
+PASS URL's constructor's base argument: http://foo.2.3.4. should throw
+PASS URL's href: http://foo.2.3.4. should throw
+PASS XHR: http://foo.2.3.4. should throw
+PASS sendBeacon(): http://foo.2.3.4. should throw
+PASS Location's href: http://foo.2.3.4. should throw
+PASS window.open(): http://foo.2.3.4. should throw
+PASS URL's constructor's base argument: http://foo.09 should throw
+PASS URL's href: http://foo.09 should throw
+PASS XHR: http://foo.09 should throw
+PASS sendBeacon(): http://foo.09 should throw
+PASS Location's href: http://foo.09 should throw
+PASS window.open(): http://foo.09 should throw
+PASS URL's constructor's base argument: http://foo.09. should throw
+PASS URL's href: http://foo.09. should throw
+PASS XHR: http://foo.09. should throw
+PASS sendBeacon(): http://foo.09. should throw
+PASS Location's href: http://foo.09. should throw
+PASS window.open(): http://foo.09. should throw
+PASS URL's constructor's base argument: http://foo.0x4 should throw
+PASS URL's href: http://foo.0x4 should throw
+PASS XHR: http://foo.0x4 should throw
+PASS sendBeacon(): http://foo.0x4 should throw
+PASS Location's href: http://foo.0x4 should throw
+PASS window.open(): http://foo.0x4 should throw
+PASS URL's constructor's base argument: http://foo.0x4. should throw
+PASS URL's href: http://foo.0x4. should throw
+PASS XHR: http://foo.0x4. should throw
+PASS sendBeacon(): http://foo.0x4. should throw
+PASS Location's href: http://foo.0x4. should throw
+PASS window.open(): http://foo.0x4. should throw
+PASS URL's constructor's base argument: http://0999999999999999999/ should throw
+PASS URL's href: http://0999999999999999999/ should throw
+PASS XHR: http://0999999999999999999/ should throw
+PASS sendBeacon(): http://0999999999999999999/ should throw
+PASS Location's href: http://0999999999999999999/ should throw
+PASS window.open(): http://0999999999999999999/ should throw
+PASS URL's constructor's base argument: http://foo.0x should throw
+PASS URL's href: http://foo.0x should throw
+PASS XHR: http://foo.0x should throw
+PASS sendBeacon(): http://foo.0x should throw
+PASS Location's href: http://foo.0x should throw
+PASS window.open(): http://foo.0x should throw
+PASS URL's constructor's base argument: http://foo.0XFfFfFfFfFfFfFfFfFfAcE123 should throw
+PASS URL's href: http://foo.0XFfFfFfFfFfFfFfFfFfAcE123 should throw
+PASS XHR: http://foo.0XFfFfFfFfFfFfFfFfFfAcE123 should throw
+PASS sendBeacon(): http://foo.0XFfFfFfFfFfFfFfFfFfAcE123 should throw
+PASS Location's href: http://foo.0XFfFfFfFfFfFfFfFfFfAcE123 should throw
+PASS window.open(): http://foo.0XFfFfFfFfFfFfFfFfFfAcE123 should throw
+PASS URL's constructor's base argument: http://💩.123/ should throw
+PASS URL's href: http://💩.123/ should throw
+PASS XHR: http://💩.123/ should throw
+PASS sendBeacon(): http://💩.123/ should throw
+PASS Location's href: http://💩.123/ should throw
+PASS window.open(): http://💩.123/ should throw
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/resources/urltestdata.json (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/resources/urltestdata.json	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/resources/urltestdata.json	2021-09-02 23:10:11 UTC (rev 281963)
@@ -3896,21 +3896,6 @@
     "search": "",
     "hash": ""
   },
-  {
-    "input": "http://0..0x300/",
-    "base": "about:blank",
-    "href": "http://0..0x300/",
-    "origin": "http://0..0x300",
-    "protocol": "http:",
-    "username": "",
-    "password": "",
-    "host": "0..0x300",
-    "hostname": "0..0x300",
-    "port": "",
-    "pathname": "/",
-    "search": "",
-    "hash": ""
-  },
   "Broken IPv6",
   {
     "input": "http://[www.google.com]/",
@@ -5162,6 +5147,36 @@
   },
   "# IPv4 parsing (via https://github.com/nodejs/node/pull/10317)",
   {
+    "input": "http://1.2.3.4/",
+    "base": "http://other.com/",
+    "href": "http://1.2.3.4/",
+    "origin": "http://1.2.3.4",
+    "protocol": "http:",
+    "username": "",
+    "password": "",
+    "host": "1.2.3.4",
+    "hostname": "1.2.3.4",
+    "port": "",
+    "pathname": "/",
+    "search": "",
+    "hash": ""
+  },
+  {
+    "input": "http://1.2.3.4./",
+    "base": "http://other.com/",
+    "href": "http://1.2.3.4/",
+    "origin": "http://1.2.3.4",
+    "protocol": "http:",
+    "username": "",
+    "password": "",
+    "host": "1.2.3.4",
+    "hostname": "1.2.3.4",
+    "port": "",
+    "pathname": "/",
+    "search": "",
+    "hash": ""
+  },
+  {
     "input": "http://192.168.257",
     "base": "http://other.com/",
     "href": "http://192.168.1.1/",
@@ -5177,6 +5192,21 @@
     "hash": ""
   },
   {
+    "input": "http://192.168.257.",
+    "base": "http://other.com/",
+    "href": "http://192.168.1.1/",
+    "origin": "http://192.168.1.1",
+    "protocol": "http:",
+    "username": "",
+    "password": "",
+    "host": "192.168.1.1",
+    "hostname": "192.168.1.1",
+    "port": "",
+    "pathname": "/",
+    "search": "",
+    "hash": ""
+  },
+  {
     "input": "http://192.168.257.com",
     "base": "http://other.com/",
     "href": "http://192.168.257.com/",
@@ -5237,6 +5267,21 @@
     "hash": ""
   },
   {
+    "input": "http://999999999.",
+    "base": "http://other.com/",
+    "href": "http://59.154.201.255/",
+    "origin": "http://59.154.201.255",
+    "protocol": "http:",
+    "username": "",
+    "password": "",
+    "host": "59.154.201.255",
+    "hostname": "59.154.201.255",
+    "port": "",
+    "pathname": "/",
+    "search": "",
+    "hash": ""
+  },
+  {
     "input": "http://999999999.com",
     "base": "http://other.com/",
     "href": "http://999999999.com/",
@@ -5317,21 +5362,6 @@
     "failure": true
   },
   {
-    "input": "http://256.256.256.256.256",
-    "base": "http://other.com/",
-    "href": "http://256.256.256.256.256/",
-    "origin": "http://256.256.256.256.256",
-    "protocol": "http:",
-    "username": "",
-    "password": "",
-    "host": "256.256.256.256.256",
-    "hostname": "256.256.256.256.256",
-    "port": "",
-    "pathname": "/",
-    "search": "",
-    "hash": ""
-  },
-  {
     "input": "https://0x.0x.0",
     "base": "about:blank",
     "href": "https://0.0.0.0/",
@@ -7299,20 +7329,6 @@
   },
   "Invalid IPv4 radix digits",
   {
-    "input": "http://0177.0.0.0189",
-    "base": "about:blank",
-    "href": "http://0177.0.0.0189/",
-    "protocol": "http:",
-    "username": "",
-    "password": "",
-    "host": "0177.0.0.0189",
-    "hostname": "0177.0.0.0189",
-    "port": "",
-    "pathname": "/",
-    "search": "",
-    "hash": ""
-  },
-  {
     "input": "http://0x7f.0.0.0x7g",
     "base": "about:blank",
     "href": "http://0x7f.0.0.0x7g/",
@@ -8031,5 +8047,165 @@
     "input": "?",
     "base": null,
     "failure": true
+  },
+  "Last component looks like a number, but not valid IPv4",
+  {
+    "input": "http://1.2.3.4.5",
+    "base": "http://other.com/",
+    "failure": true
+  },
+  {
+    "input": "http://1.2.3.4.5.",
+    "base": "http://other.com/",
+    "failure": true
+  },
+  {
+    "input": "http://0..0x300/",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://0..0x300./",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://256.256.256.256.256",
+    "base": "http://other.com/",
+    "failure": true
+  },
+  {
+    "input": "http://256.256.256.256.256.",
+    "base": "http://other.com/",
+    "failure": true
+  },
+  {
+    "input": "http://1.2.3.08",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://1.2.3.08.",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://1.2.3.09",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://09.2.3.4",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://09.2.3.4.",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://01.2.3.4.5",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://01.2.3.4.5.",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://0x100.2.3.4",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://0x100.2.3.4.",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://0x1.2.3.4.5",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://0x1.2.3.4.5.",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.1.2.3.4",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.1.2.3.4.",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.2.3.4",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.2.3.4.",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.09",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.09.",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.0x4",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.0x4.",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.09..",
+    "base": "about:blank",
+    "hash": "",
+    "host": "foo.09..",
+    "hostname": "foo.09..",
+    "href":"http://foo.09../",
+    "password": "",
+    "pathname": "/",
+    "port":"",
+    "protocol": "http:",
+    "search": "",
+    "username": ""
+  },
+  {
+    "input": "http://0999999999999999999/",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.0x",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://foo.0XFfFfFfFfFfFfFfFfFfAcE123",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "http://💩.123/",
+    "base": "about:blank",
+    "failure": true
   }
 ]

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -296,7 +296,6 @@
 PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
 PASS Parsing: <http://./> against <about:blank>
 PASS Parsing: <http://../> against <about:blank>
-PASS Parsing: <http://0..0x300/> against <about:blank>
 PASS Parsing: <http://[www.google.com]/> against <about:blank>
 PASS Parsing: <http://[google.com]> against <http://other.com/>
 PASS Parsing: <http://[::1.2.3.4x]> against <http://other.com/>
@@ -420,11 +419,15 @@
 PASS Parsing: <http://foo.bar/baz?qux#foo<bar> against <about:blank>
 PASS Parsing: <http://foo.bar/baz?qux#foo>bar> against <about:blank>
 PASS Parsing: <http://foo.bar/baz?qux#foo`bar> against <about:blank>
+PASS Parsing: <http://1.2.3.4/> against <http://other.com/>
+PASS Parsing: <http://1.2.3.4./> against <http://other.com/>
 PASS Parsing: <http://192.168.257> against <http://other.com/>
+PASS Parsing: <http://192.168.257.> against <http://other.com/>
 PASS Parsing: <http://192.168.257.com> against <http://other.com/>
 PASS Parsing: <http://256> against <http://other.com/>
 PASS Parsing: <http://256.com> against <http://other.com/>
 PASS Parsing: <http://999999999> against <http://other.com/>
+PASS Parsing: <http://999999999.> against <http://other.com/>
 PASS Parsing: <http://999999999.com> against <http://other.com/>
 PASS Parsing: <http://10000000000> against <http://other.com/>
 PASS Parsing: <http://10000000000.com> against <http://other.com/>
@@ -433,7 +436,6 @@
 PASS Parsing: <http://0xffffffff> against <http://other.com/>
 PASS Parsing: <http://0xffffffff1> against <http://other.com/>
 PASS Parsing: <http://256.256.256.256> against <http://other.com/>
-PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
 PASS Parsing: <https://0x.0x.0> against <about:blank>
 PASS Parsing: <https://0x100000000/test> against <about:blank>
 PASS Parsing: <https://256.0.0.1/test> against <about:blank>
@@ -588,7 +590,6 @@
 PASS Parsing: <non-special://[:80/> against <about:blank>
 PASS Parsing: <blob:https://example.com:443/> against <about:blank>
 PASS Parsing: <blob:d3958f5c-0777-0845-9dcf-2cb28783acaf> against <about:blank>
-PASS Parsing: <http://0177.0.0.0189> against <about:blank>
 PASS Parsing: <http://0x7f.0.0.0x7g> against <about:blank>
 PASS Parsing: <http://0X7F.0.0.0X7G> against <about:blank>
 PASS Parsing: <http://[::127.0.0.0.1]> against <about:blank>
@@ -645,4 +646,34 @@
 PASS Parsing: <abc:/rooted> against <abc://host/path>
 PASS Parsing: <#> against <null>
 PASS Parsing: <?> against <null>
+PASS Parsing: <http://1.2.3.4.5> against <http://other.com/>
+PASS Parsing: <http://1.2.3.4.5.> against <http://other.com/>
+PASS Parsing: <http://0..0x300/> against <about:blank>
+PASS Parsing: <http://0..0x300./> against <about:blank>
+PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256.256.> against <http://other.com/>
+PASS Parsing: <http://1.2.3.08> against <about:blank>
+PASS Parsing: <http://1.2.3.08.> against <about:blank>
+PASS Parsing: <http://1.2.3.09> against <about:blank>
+PASS Parsing: <http://09.2.3.4> against <about:blank>
+PASS Parsing: <http://09.2.3.4.> against <about:blank>
+PASS Parsing: <http://01.2.3.4.5> against <about:blank>
+PASS Parsing: <http://01.2.3.4.5.> against <about:blank>
+PASS Parsing: <http://0x100.2.3.4> against <about:blank>
+PASS Parsing: <http://0x100.2.3.4.> against <about:blank>
+PASS Parsing: <http://0x1.2.3.4.5> against <about:blank>
+PASS Parsing: <http://0x1.2.3.4.5.> against <about:blank>
+PASS Parsing: <http://foo.1.2.3.4> against <about:blank>
+PASS Parsing: <http://foo.1.2.3.4.> against <about:blank>
+PASS Parsing: <http://foo.2.3.4> against <about:blank>
+PASS Parsing: <http://foo.2.3.4.> against <about:blank>
+PASS Parsing: <http://foo.09> against <about:blank>
+PASS Parsing: <http://foo.09.> against <about:blank>
+PASS Parsing: <http://foo.0x4> against <about:blank>
+PASS Parsing: <http://foo.0x4.> against <about:blank>
+PASS Parsing: <http://foo.09..> against <about:blank>
+PASS Parsing: <http://0999999999999999999/> against <about:blank>
+PASS Parsing: <http://foo.0x> against <about:blank>
+PASS Parsing: <http://foo.0XFfFfFfFfFfFfFfFfFfAcE123> against <about:blank>
+PASS Parsing: <http://💩.123/> against <about:blank>
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any.worker-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any.worker-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any.worker-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -296,7 +296,6 @@
 PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
 PASS Parsing: <http://./> against <about:blank>
 PASS Parsing: <http://../> against <about:blank>
-PASS Parsing: <http://0..0x300/> against <about:blank>
 PASS Parsing: <http://[www.google.com]/> against <about:blank>
 PASS Parsing: <http://[google.com]> against <http://other.com/>
 PASS Parsing: <http://[::1.2.3.4x]> against <http://other.com/>
@@ -420,11 +419,15 @@
 PASS Parsing: <http://foo.bar/baz?qux#foo<bar> against <about:blank>
 PASS Parsing: <http://foo.bar/baz?qux#foo>bar> against <about:blank>
 PASS Parsing: <http://foo.bar/baz?qux#foo`bar> against <about:blank>
+PASS Parsing: <http://1.2.3.4/> against <http://other.com/>
+PASS Parsing: <http://1.2.3.4./> against <http://other.com/>
 PASS Parsing: <http://192.168.257> against <http://other.com/>
+PASS Parsing: <http://192.168.257.> against <http://other.com/>
 PASS Parsing: <http://192.168.257.com> against <http://other.com/>
 PASS Parsing: <http://256> against <http://other.com/>
 PASS Parsing: <http://256.com> against <http://other.com/>
 PASS Parsing: <http://999999999> against <http://other.com/>
+PASS Parsing: <http://999999999.> against <http://other.com/>
 PASS Parsing: <http://999999999.com> against <http://other.com/>
 PASS Parsing: <http://10000000000> against <http://other.com/>
 PASS Parsing: <http://10000000000.com> against <http://other.com/>
@@ -433,7 +436,6 @@
 PASS Parsing: <http://0xffffffff> against <http://other.com/>
 PASS Parsing: <http://0xffffffff1> against <http://other.com/>
 PASS Parsing: <http://256.256.256.256> against <http://other.com/>
-PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
 PASS Parsing: <https://0x.0x.0> against <about:blank>
 PASS Parsing: <https://0x100000000/test> against <about:blank>
 PASS Parsing: <https://256.0.0.1/test> against <about:blank>
@@ -588,7 +590,6 @@
 PASS Parsing: <non-special://[:80/> against <about:blank>
 PASS Parsing: <blob:https://example.com:443/> against <about:blank>
 PASS Parsing: <blob:d3958f5c-0777-0845-9dcf-2cb28783acaf> against <about:blank>
-PASS Parsing: <http://0177.0.0.0189> against <about:blank>
 PASS Parsing: <http://0x7f.0.0.0x7g> against <about:blank>
 PASS Parsing: <http://0X7F.0.0.0X7G> against <about:blank>
 PASS Parsing: <http://[::127.0.0.0.1]> against <about:blank>
@@ -645,4 +646,34 @@
 PASS Parsing: <abc:/rooted> against <abc://host/path>
 PASS Parsing: <#> against <null>
 PASS Parsing: <?> against <null>
+PASS Parsing: <http://1.2.3.4.5> against <http://other.com/>
+PASS Parsing: <http://1.2.3.4.5.> against <http://other.com/>
+PASS Parsing: <http://0..0x300/> against <about:blank>
+PASS Parsing: <http://0..0x300./> against <about:blank>
+PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256.256.> against <http://other.com/>
+PASS Parsing: <http://1.2.3.08> against <about:blank>
+PASS Parsing: <http://1.2.3.08.> against <about:blank>
+PASS Parsing: <http://1.2.3.09> against <about:blank>
+PASS Parsing: <http://09.2.3.4> against <about:blank>
+PASS Parsing: <http://09.2.3.4.> against <about:blank>
+PASS Parsing: <http://01.2.3.4.5> against <about:blank>
+PASS Parsing: <http://01.2.3.4.5.> against <about:blank>
+PASS Parsing: <http://0x100.2.3.4> against <about:blank>
+PASS Parsing: <http://0x100.2.3.4.> against <about:blank>
+PASS Parsing: <http://0x1.2.3.4.5> against <about:blank>
+PASS Parsing: <http://0x1.2.3.4.5.> against <about:blank>
+PASS Parsing: <http://foo.1.2.3.4> against <about:blank>
+PASS Parsing: <http://foo.1.2.3.4.> against <about:blank>
+PASS Parsing: <http://foo.2.3.4> against <about:blank>
+PASS Parsing: <http://foo.2.3.4.> against <about:blank>
+PASS Parsing: <http://foo.09> against <about:blank>
+PASS Parsing: <http://foo.09.> against <about:blank>
+PASS Parsing: <http://foo.0x4> against <about:blank>
+PASS Parsing: <http://foo.0x4.> against <about:blank>
+PASS Parsing: <http://foo.09..> against <about:blank>
+PASS Parsing: <http://0999999999999999999/> against <about:blank>
+PASS Parsing: <http://foo.0x> against <about:blank>
+PASS Parsing: <http://foo.0XFfFfFfFfFfFfFfFfFfAcE123> against <about:blank>
+PASS Parsing: <http://💩.123/> against <about:blank>
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-origin.any-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-origin.any-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-origin.any-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -220,7 +220,6 @@
 PASS Origin parsing: <http://0Xc0.0250.01> against <http://other.com/>
 PASS Origin parsing: <http://./> against <about:blank>
 PASS Origin parsing: <http://../> against <about:blank>
-PASS Origin parsing: <http://0..0x300/> against <about:blank>
 PASS Origin parsing: <http://foo:💩@example.com/bar> against <http://other.com/>
 PASS Origin parsing: <#> against <test:test>
 PASS Origin parsing: <#x> against <mailto:[email protected]>
@@ -287,16 +286,19 @@
 PASS Origin parsing: <http://foo.bar/baz?qux#foo<bar> against <about:blank>
 PASS Origin parsing: <http://foo.bar/baz?qux#foo>bar> against <about:blank>
 PASS Origin parsing: <http://foo.bar/baz?qux#foo`bar> against <about:blank>
+PASS Origin parsing: <http://1.2.3.4/> against <http://other.com/>
+PASS Origin parsing: <http://1.2.3.4./> against <http://other.com/>
 PASS Origin parsing: <http://192.168.257> against <http://other.com/>
+PASS Origin parsing: <http://192.168.257.> against <http://other.com/>
 PASS Origin parsing: <http://192.168.257.com> against <http://other.com/>
 PASS Origin parsing: <http://256> against <http://other.com/>
 PASS Origin parsing: <http://256.com> against <http://other.com/>
 PASS Origin parsing: <http://999999999> against <http://other.com/>
+PASS Origin parsing: <http://999999999.> against <http://other.com/>
 PASS Origin parsing: <http://999999999.com> against <http://other.com/>
 PASS Origin parsing: <http://10000000000.com> against <http://other.com/>
 PASS Origin parsing: <http://4294967295> against <http://other.com/>
 PASS Origin parsing: <http://0xffffffff> against <http://other.com/>
-PASS Origin parsing: <http://256.256.256.256.256> against <http://other.com/>
 PASS Origin parsing: <https://0x.0x.0> against <about:blank>
 PASS Origin parsing: <asdf://%43%7C/> against <about:blank>
 PASS Origin parsing: <http://[1:0::]> against <http://example.net/>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-origin.any.worker-expected.txt (281962 => 281963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-origin.any.worker-expected.txt	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-origin.any.worker-expected.txt	2021-09-02 23:10:11 UTC (rev 281963)
@@ -220,7 +220,6 @@
 PASS Origin parsing: <http://0Xc0.0250.01> against <http://other.com/>
 PASS Origin parsing: <http://./> against <about:blank>
 PASS Origin parsing: <http://../> against <about:blank>
-PASS Origin parsing: <http://0..0x300/> against <about:blank>
 PASS Origin parsing: <http://foo:💩@example.com/bar> against <http://other.com/>
 PASS Origin parsing: <#> against <test:test>
 PASS Origin parsing: <#x> against <mailto:[email protected]>
@@ -287,16 +286,19 @@
 PASS Origin parsing: <http://foo.bar/baz?qux#foo<bar> against <about:blank>
 PASS Origin parsing: <http://foo.bar/baz?qux#foo>bar> against <about:blank>
 PASS Origin parsing: <http://foo.bar/baz?qux#foo`bar> against <about:blank>
+PASS Origin parsing: <http://1.2.3.4/> against <http://other.com/>
+PASS Origin parsing: <http://1.2.3.4./> against <http://other.com/>
 PASS Origin parsing: <http://192.168.257> against <http://other.com/>
+PASS Origin parsing: <http://192.168.257.> against <http://other.com/>
 PASS Origin parsing: <http://192.168.257.com> against <http://other.com/>
 PASS Origin parsing: <http://256> against <http://other.com/>
 PASS Origin parsing: <http://256.com> against <http://other.com/>
 PASS Origin parsing: <http://999999999> against <http://other.com/>
+PASS Origin parsing: <http://999999999.> against <http://other.com/>
 PASS Origin parsing: <http://999999999.com> against <http://other.com/>
 PASS Origin parsing: <http://10000000000.com> against <http://other.com/>
 PASS Origin parsing: <http://4294967295> against <http://other.com/>
 PASS Origin parsing: <http://0xffffffff> against <http://other.com/>
-PASS Origin parsing: <http://256.256.256.256.256> against <http://other.com/>
 PASS Origin parsing: <https://0x.0x.0> against <about:blank>
 PASS Origin parsing: <asdf://%43%7C/> against <about:blank>
 PASS Origin parsing: <http://[1:0::]> against <http://example.net/>

Modified: trunk/Source/WTF/ChangeLog (281962 => 281963)


--- trunk/Source/WTF/ChangeLog	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/Source/WTF/ChangeLog	2021-09-02 23:10:11 UTC (rev 281963)
@@ -1,3 +1,25 @@
+2021-09-02  Alex Christensen  <[email protected]>
+
+        Reject non-IPv4 hostnames that end in numbers
+        https://bugs.webkit.org/show_bug.cgi?id=228826
+
+        Reviewed by Tim Horton.
+
+        This implements a recent change to the URL specification at https://github.com/whatwg/url/pull/619
+        Chrome has made the same change in https://crbug.com/1237032
+
+        Since there are no TLDs that are only numbers and some think it might be confusing to have a valid URL
+        like http://example.com.127.0.0.1/ we prevent URLs that end in a segment between dots that contains only
+        numbers from parsing successfully.
+
+        * wtf/URLParser.cpp:
+        (WTF::URLParser::parse):
+        (WTF::dnsNameEndsInNumber):
+        (WTF::URLParser::parseHostAndPort):
+        I give more information in the return type so one can tell what the code is doing.
+        We only check if it is valid or not, but for documentation purposes I think it's useful to return more information.
+        * wtf/URLParser.h:
+
 2021-09-02  Mark Lam  <[email protected]>
 
         Add more support for JIT operation validation testing.

Modified: trunk/Source/WTF/wtf/URLParser.cpp (281962 => 281963)


--- trunk/Source/WTF/wtf/URLParser.cpp	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/Source/WTF/wtf/URLParser.cpp	2021-09-02 23:10:11 UTC (rev 281963)
@@ -1438,7 +1438,7 @@
                     } else {
                         m_url.m_userEnd = currentPosition(authorityOrHostBegin);
                         m_url.m_passwordEnd = m_url.m_userEnd;
-                        if (!parseHostAndPort(iterator)) {
+                        if (parseHostAndPort(iterator) == HostParsingResult::InvalidHost) {
                             failure();
                             return;
                         }
@@ -1462,7 +1462,7 @@
             do {
                 LOG_STATE("Host");
                 if (*c == '/' || *c == '?' || *c == '#') {
-                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
+                    if (parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c)) == HostParsingResult::InvalidHost) {
                         failure();
                         return;
                     }
@@ -1656,7 +1656,7 @@
                         state = State::Path;
                         break;
                     }
-                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
+                    if (parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c)) == HostParsingResult::InvalidHost) {
                         failure();
                         return;
                     }
@@ -1849,7 +1849,7 @@
             m_url.m_hostEnd = m_url.m_userStart;
             m_url.m_portLength = 0;
             m_url.m_pathEnd = m_url.m_userStart;
-        } else if (!parseHostAndPort(authorityOrHostBegin)) {
+        } else if (parseHostAndPort(authorityOrHostBegin) == HostParsingResult::InvalidHost) {
             failure();
             return;
         } else {
@@ -1865,7 +1865,7 @@
         break;
     case State::Host:
         LOG_FINAL_STATE("Host");
-        if (!parseHostAndPort(authorityOrHostBegin)) {
+        if (parseHostAndPort(authorityOrHostBegin) == HostParsingResult::InvalidHost) {
             failure();
             return;
         }
@@ -1954,7 +1954,7 @@
             break;
         }
 
-        if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
+        if (parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c)) == HostParsingResult::InvalidHost) {
             failure();
             return;
         }
@@ -2692,19 +2692,56 @@
     return subdomainStartsWithXNDashDash(CodePointIterator<UChar>(begin, begin + host.length()));
 }
 
+static bool dnsNameEndsInNumber(StringView name)
+{
+    // https://url.spec.whatwg.org/#ends-in-a-number-checker
+    auto containsOctalDecimalOrHexNumber = [] (StringView segment) {
+        auto isNonDigit = [](UChar c) {
+            return !isASCIIDigit(c);
+        };
+        const auto segmentLength = segment.length();
+        if (!UNLIKELY(segmentLength))
+            return false;
+        auto firstCodeUnit = segment[0];
+        if (LIKELY(isNonDigit(firstCodeUnit)))
+            return false;
+        if (segmentLength == 1)
+            return true;
+        auto secondCodeUnit = segment[1];
+        if ((secondCodeUnit == 'x' || secondCodeUnit == 'X') && firstCodeUnit == '0') {
+            auto isNonHexDigit = [](UChar c) {
+                return !isASCIIHexDigit(c);
+            };
+            return segment.find(isNonHexDigit, 2) == notFound;
+        }
+        return segment.find(isNonDigit) == notFound;
+    };
+
+    size_t lastDotLocation = name.reverseFind('.');
+    if (lastDotLocation == notFound)
+        return containsOctalDecimalOrHexNumber(name);
+    size_t lastSegmentEnd = name.length();
+    if (lastDotLocation == lastSegmentEnd - 1) {
+        lastSegmentEnd = lastDotLocation;
+        lastDotLocation = name.reverseFind('.', lastDotLocation - 1);
+    }
+    StringView lastPart = name.substring(lastDotLocation == notFound ? 0 : lastDotLocation + 1, lastSegmentEnd - lastDotLocation - 1);
+    return containsOctalDecimalOrHexNumber(lastPart);
+}
+
 template<typename CharacterType>
-bool URLParser::parseHostAndPort(CodePointIterator<CharacterType> iterator)
+auto URLParser::parseHostAndPort(CodePointIterator<CharacterType> iterator) -> HostParsingResult
 {
     if (iterator.atEnd())
-        return false;
+        return HostParsingResult::InvalidHost;
     if (*iterator == ':')
-        return false;
+        return HostParsingResult::InvalidHost;
     if (*iterator == '[') {
         auto ipv6End = iterator;
         while (!ipv6End.atEnd() && *ipv6End != ']')
             ++ipv6End;
         if (ipv6End.atEnd())
-            return false;
+            return HostParsingResult::InvalidHost;
         if (auto address = parseIPv6Host(CodePointIterator<CharacterType>(iterator, ipv6End))) {
             serializeIPv6(address.value());
             if (!ipv6End.atEnd()) {
@@ -2711,14 +2748,14 @@
                 advance(ipv6End);
                 m_url.m_hostEnd = currentPosition(ipv6End);
                 if (!ipv6End.atEnd() && *ipv6End == ':')
-                    return parsePort(ipv6End);
+                    return parsePort(ipv6End) ? HostParsingResult::IPv6WithPort : HostParsingResult::InvalidHost;
                 m_url.m_portLength = 0;
-                return ipv6End.atEnd();
+                return ipv6End.atEnd() ? HostParsingResult::IPv6WithoutPort : HostParsingResult::InvalidHost;
             }
             m_url.m_hostEnd = currentPosition(ipv6End);
-            return true;
+            return HostParsingResult::IPv6WithoutPort;
         }
-        return false;
+        return HostParsingResult::InvalidHost;
     }
 
     if (!m_urlIsSpecial) {
@@ -2730,15 +2767,15 @@
             if (*iterator == ':')
                 break;
             if (UNLIKELY(isForbiddenHostCodePoint(*iterator) && *iterator != '%'))
-                return false;
+                return HostParsingResult::InvalidHost;
             utf8PercentEncode<isInSimpleEncodeSet>(iterator);
         }
         m_url.m_hostEnd = currentPosition(iterator);
         if (iterator.atEnd()) {
             m_url.m_portLength = 0;
-            return true;
+            return HostParsingResult::NonSpecialHostWithoutPort;
         }
-        return parsePort(iterator);
+        return parsePort(iterator) ? HostParsingResult::NonSpecialHostWithPort : HostParsingResult::InvalidHost;
     }
     
     if (LIKELY(!m_hostHasPercentOrNonASCII && !subdomainStartsWithXNDashDash(iterator))) {
@@ -2749,7 +2786,7 @@
             if (*iterator == ':')
                 break;
             if (isForbiddenHostCodePoint(*iterator))
-                return false;
+                return HostParsingResult::InvalidHost;
         }
         auto address = parseIPv4Host(hostIterator, CodePointIterator<CharacterType>(hostIterator, iterator));
         if (address) {
@@ -2757,12 +2794,12 @@
             m_url.m_hostEnd = currentPosition(iterator);
             if (iterator.atEnd()) {
                 m_url.m_portLength = 0;
-                return true;
+                return HostParsingResult::IPv4WithoutPort;
             }
-            return parsePort(iterator);
+            return parsePort(iterator) ? HostParsingResult::IPv4WithPort : HostParsingResult::InvalidHost;
         }
         if (address.error() == IPv4ParsingError::Failure)
-            return false;
+            return HostParsingResult::InvalidHost;
         for (; hostIterator != iterator; ++hostIterator) {
             if (UNLIKELY(isTabOrNewline(*hostIterator))) {
                 syntaxViolation(hostIterator);
@@ -2773,12 +2810,13 @@
             appendToASCIIBuffer(toASCIILower(*hostIterator));
         }
         m_url.m_hostEnd = currentPosition(iterator);
+        auto hostStart = m_url.hostStart();
+        if (UNLIKELY(dnsNameEndsInNumber(parsedDataView(hostStart, m_url.m_hostEnd - hostStart))))
+            return HostParsingResult::InvalidHost;
         if (!hostIterator.atEnd())
-            return parsePort(hostIterator);
-        unsigned portLength = currentPosition(iterator) - m_url.m_hostEnd;
-        RELEASE_ASSERT(portLength <= URL::maxPortLength);
-        m_url.m_portLength = portLength;
-        return true;
+            return parsePort(hostIterator) ? HostParsingResult::DNSNameWithPort : HostParsingResult::InvalidHost;
+        m_url.m_portLength = 0;
+        return HostParsingResult::DNSNameWithoutPort;
     }
     
     const auto hostBegin = iterator;
@@ -2799,18 +2837,18 @@
         UBool isError = false;
         U8_APPEND(buffer, offset, U8_MAX_LENGTH, *iterator, isError);
         if (isError)
-            return false;
+            return HostParsingResult::InvalidHost;
         utf8Encoded.append(buffer, offset);
     }
     LCharBuffer percentDecoded = percentDecode(utf8Encoded.data(), utf8Encoded.size(), hostBegin);
     String domain = String::fromUTF8(percentDecoded.data(), percentDecoded.size());
     if (domain.isNull())
-        return false;
+        return HostParsingResult::InvalidHost;
     if (domain != StringView(percentDecoded.data(), percentDecoded.size()))
         syntaxViolation(hostBegin);
     auto asciiDomain = domainToASCII(*domain.impl(), hostBegin);
     if (!asciiDomain || hasForbiddenHostCodePoint(asciiDomain.value()))
-        return false;
+        return HostParsingResult::InvalidHost;
     LCharBuffer& asciiDomainValue = asciiDomain.value();
     const LChar* asciiDomainCharacters = asciiDomainValue.data();
 
@@ -2820,19 +2858,23 @@
         m_url.m_hostEnd = currentPosition(iterator);
         if (iterator.atEnd()) {
             m_url.m_portLength = 0;
-            return true;
+            return HostParsingResult::IPv4WithoutPort;
         }
-        return parsePort(iterator);
+        return parsePort(iterator) ? HostParsingResult::IPv4WithPort : HostParsingResult::InvalidHost;
     }
     if (address.error() == IPv4ParsingError::Failure)
-        return false;
+        return HostParsingResult::InvalidHost;
 
     appendToASCIIBuffer(asciiDomainCharacters, asciiDomainValue.size());
     m_url.m_hostEnd = currentPosition(iterator);
+    auto hostStart = m_url.hostStart();
+    if (UNLIKELY(dnsNameEndsInNumber(parsedDataView(hostStart, m_url.m_hostEnd - hostStart))))
+        return HostParsingResult::InvalidHost;
     if (!iterator.atEnd())
-        return parsePort(iterator);
+        return parsePort(iterator) ? HostParsingResult::DNSNameWithPort : HostParsingResult::InvalidHost;
+
     m_url.m_portLength = 0;
-    return true;
+    return HostParsingResult::DNSNameWithoutPort;
 }
 
 std::optional<String> URLParser::formURLDecode(StringView input)

Modified: trunk/Source/WTF/wtf/URLParser.h (281962 => 281963)


--- trunk/Source/WTF/wtf/URLParser.h	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/Source/WTF/wtf/URLParser.h	2021-09-02 23:10:11 UTC (rev 281963)
@@ -88,7 +88,8 @@
 
     template<typename CharacterType> void parse(const CharacterType*, const unsigned length, const URL&, const URLTextEncoding*);
     template<typename CharacterType> void parseAuthority(CodePointIterator<CharacterType>);
-    template<typename CharacterType> bool parseHostAndPort(CodePointIterator<CharacterType>);
+    enum class HostParsingResult : uint8_t { InvalidHost, IPv6WithPort, IPv6WithoutPort, IPv4WithPort, IPv4WithoutPort, DNSNameWithPort, DNSNameWithoutPort, NonSpecialHostWithoutPort, NonSpecialHostWithPort };
+    template<typename CharacterType> HostParsingResult parseHostAndPort(CodePointIterator<CharacterType>);
     template<typename CharacterType> bool parsePort(CodePointIterator<CharacterType>&);
 
     void failure();

Modified: trunk/Tools/ChangeLog (281962 => 281963)


--- trunk/Tools/ChangeLog	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/Tools/ChangeLog	2021-09-02 23:10:11 UTC (rev 281963)
@@ -1,3 +1,14 @@
+2021-09-02  Alex Christensen  <[email protected]>
+
+        Reject non-IPv4 hostnames that end in numbers
+        https://bugs.webkit.org/show_bug.cgi?id=228826
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WTF/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+        Update expectations for a few strange URLs that are no longer valid.
+
 2021-09-02  Carlos Alberto Lopez Perez  <[email protected]>
 
         [run-perf-tests] Add support for python3 and use it by default

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp (281962 => 281963)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp	2021-09-02 23:06:58 UTC (rev 281962)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp	2021-09-02 23:10:11 UTC (rev 281963)
@@ -378,7 +378,7 @@
     checkURL("http://127.0.0.1:/\tpath", {"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("ws://08./", {"ws", "", "", "08.", 0, "/", "", "", "ws://08./"});
+    shouldFail("ws://08./");
     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:0:0:f:\t:]:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"});
@@ -409,8 +409,8 @@
     checkURL("http:/a", {"http", "", "", "a", 0, "/", "", "", "http://a/"});
     checkURL("http://256../", {"http", "", "", "256..", 0, "/", "", "", "http://256../"});
     checkURL("http://256..", {"http", "", "", "256..", 0, "/", "", "", "http://256../"});
-    checkURL("http://127..1/", {"http", "", "", "127..1", 0, "/", "", "", "http://127..1/"});
-    checkURL("http://127.a.0.1/", {"http", "", "", "127.a.0.1", 0, "/", "", "", "http://127.a.0.1/"});
+    shouldFail("http://127..1/");
+    shouldFail("http://127.a.0.1/");
     checkURL("http://127.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
     checkURL("http://12\t7.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
     checkURL("http://127.\t0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to