Skip to content

Commit

Permalink
Cherry-pick 274915@main (953476d). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=265484

    URLParser should parse URLs including authority and a backslash after the host
    https://bugs.webkit.org/show_bug.cgi?id=265484
    rdar://119219832

    Reviewed by Alex Christensen.

    Thanks to dave caruso for reporting and suggesting a fix.

    Tests are synchronized up to and including this PR:
    web-platform-tests/wpt#44637

    * LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-xhtml-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml_exclude=(file_javascript_mailto)-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml_include=file-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/a-element_exclude=(file_javascript_mailto)-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/a-element_include=file-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/failure.html:
    * LayoutTests/imported/w3c/web-platform-tests/url/resources/urltestdata.json:
    * LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any.worker_exclude=(file_javascript_mailto)-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any.worker_include=file-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any_exclude=(file_javascript_mailto)-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any_include=file-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/url-origin.any-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/url-origin.any.worker-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/url-statics-canparse.any-expected.txt:
    * LayoutTests/imported/w3c/web-platform-tests/url/url-statics-canparse.any.js:
    * LayoutTests/imported/w3c/web-platform-tests/url/url-statics-canparse.any.worker-expected.txt:
    * Source/WTF/wtf/URLParser.cpp:
    (WTF::URLParser::parse):
    * Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp:
    (TestWebKitAPI::TEST_F):

    Canonical link: https://commits.webkit.org/274915@main
  • Loading branch information
annevk authored and aperezdc committed Mar 8, 2024
1 parent f91ce85 commit 0264501
Show file tree
Hide file tree
Showing 19 changed files with 263 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ PASS Parsing origin: <http://foo.com:b@d/> against <http://example.org/foo/bar>
PASS Parsing origin: <http://foo.com/\@> against <http://example.org/foo/bar>
PASS Parsing origin: <http:\\foo.com\> against <http://example.org/foo/bar>
PASS Parsing origin: <http:\\a\b:c\d@foo.com\> against <http://example.org/foo/bar>
PASS Parsing origin: <http://a:b@c\> against <about:blank>
PASS Parsing origin: <ws://a@b\c> against <about:blank>
PASS Parsing origin: <foo:/> against <http://example.org/foo/bar>
PASS Parsing origin: <foo:/bar.com/> against <http://example.org/foo/bar>
PASS Parsing origin: <foo://///////> against <http://example.org/foo/bar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ PASS Parsing origin: <http://foo.com:b@d/> against <http://example.org/foo/bar>
PASS Parsing origin: <http://foo.com/\@> against <http://example.org/foo/bar>
PASS Parsing origin: <http:\\foo.com\> against <http://example.org/foo/bar>
PASS Parsing origin: <http:\\a\b:c\d@foo.com\> against <http://example.org/foo/bar>
PASS Parsing origin: <http://a:b@c\> against <about:blank>
PASS Parsing origin: <ws://a@b\c> against <about:blank>
PASS Parsing origin: <foo:/> against <http://example.org/foo/bar>
PASS Parsing origin: <foo:/bar.com/> against <http://example.org/foo/bar>
PASS Parsing origin: <foo://///////> against <http://example.org/foo/bar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ PASS Parsing: <http://foo.com:b@d/> against <http://example.org/foo/bar>
PASS Parsing: <http://foo.com/\@> against <http://example.org/foo/bar>
PASS Parsing: <http:\\foo.com\> against <http://example.org/foo/bar>
PASS Parsing: <http:\\a\b:c\d@foo.com\> against <http://example.org/foo/bar>
PASS Parsing: <http://a:b@c\> against <about:blank>
PASS Parsing: <ws://a@b\c> against <about:blank>
PASS Parsing: <foo:/> against <http://example.org/foo/bar>
PASS Parsing: <foo:/bar.com/> against <http://example.org/foo/bar>
PASS Parsing: <foo://///////> against <http://example.org/foo/bar>
Expand Down Expand Up @@ -684,4 +686,12 @@ PASS Parsing: <stun://test:test> against <about:blank>
PASS Parsing: <stun://[:1]> against <about:blank>
PASS Parsing: <w://x:0> against <about:blank>
PASS Parsing: <west://x:0> against <about:blank>
PASS Parsing: <///test> against <http://example.org/>
PASS Parsing: <///\//\//test> against <http://example.org/>
PASS Parsing: <///example.org/path> against <http://example.org/>
PASS Parsing: <///example.org/../path> against <http://example.org/>
PASS Parsing: <///example.org/../../> against <http://example.org/>
PASS Parsing: <///example.org/../path/../../> against <http://example.org/>
PASS Parsing: <///example.org/../path/../../path> against <http://example.org/>
PASS Parsing: </\/\//example.org/../path> against <http://example.org/>

Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,7 @@ PASS Parsing: <file://­/p> against <about:blank>
PASS Parsing: <file://%C2%AD/p> against <about:blank>
PASS Parsing: <file://xn--/p> against <about:blank>
PASS Parsing: <> against <about:blank>
PASS Parsing: <///abcdef/../> against <file:///>
PASS Parsing: </\//\/a/../> against <file:///>
PASS Parsing: <//a/../> against <file:///>

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ PASS Parsing: <http://foo.com:b@d/> against <http://example.org/foo/bar>
PASS Parsing: <http://foo.com/\@> against <http://example.org/foo/bar>
PASS Parsing: <http:\\foo.com\> against <http://example.org/foo/bar>
PASS Parsing: <http:\\a\b:c\d@foo.com\> against <http://example.org/foo/bar>
PASS Parsing: <http://a:b@c\> against <about:blank>
PASS Parsing: <ws://a@b\c> against <about:blank>
PASS Parsing: <foo:/> against <http://example.org/foo/bar>
PASS Parsing: <foo:/bar.com/> against <http://example.org/foo/bar>
PASS Parsing: <foo://///////> against <http://example.org/foo/bar>
Expand Down Expand Up @@ -684,4 +686,12 @@ PASS Parsing: <stun://test:test> against <about:blank>
PASS Parsing: <stun://[:1]> against <about:blank>
PASS Parsing: <w://x:0> against <about:blank>
PASS Parsing: <west://x:0> against <about:blank>
PASS Parsing: <///test> against <http://example.org/>
PASS Parsing: <///\//\//test> against <http://example.org/>
PASS Parsing: <///example.org/path> against <http://example.org/>
PASS Parsing: <///example.org/../path> against <http://example.org/>
PASS Parsing: <///example.org/../../> against <http://example.org/>
PASS Parsing: <///example.org/../path/../../> against <http://example.org/>
PASS Parsing: <///example.org/../path/../../path> against <http://example.org/>
PASS Parsing: </\/\//example.org/../path> against <http://example.org/>

Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,7 @@ PASS Parsing: <file://­/p> against <about:blank>
PASS Parsing: <file://%C2%AD/p> against <about:blank>
PASS Parsing: <file://xn--/p> against <about:blank>
PASS Parsing: <> against <about:blank>
PASS Parsing: <///abcdef/../> against <file:///>
PASS Parsing: </\//\/a/../> against <file:///>
PASS Parsing: <//a/../> against <file:///>

2 changes: 2 additions & 0 deletions LayoutTests/imported/w3c/web-platform-tests/url/failure.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

function runTests(testData) {
for (const test of testData) {

// skip comments, inputs we expect to pass and relative URLs
if (typeof test === "string" || !test.failure || test.base !== null) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,36 @@
"search": "",
"hash": ""
},
{
"input": "http://a:b@c\\",
"base": null,
"href": "http://a:b@c/",
"origin": "http://c",
"protocol": "http:",
"username": "a",
"password": "b",
"host": "c",
"hostname": "c",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "ws://a@b\\c",
"base": null,
"href": "ws://a@b/c",
"origin": "ws://b",
"protocol": "ws:",
"username": "a",
"password": "",
"host": "b",
"hostname": "b",
"port": "",
"pathname": "/c",
"search": "",
"hash": ""
},
{
"input": "foo:/",
"base": "http://example.org/foo/bar",
Expand Down Expand Up @@ -9530,5 +9560,160 @@
"pathname": "",
"search": "",
"hash": ""
},
"Scheme relative path starting with multiple slashes",
{
"input": "///test",
"base": "http://example.org/",
"href": "http://test/",
"protocol": "http:",
"username": "",
"password": "",
"host": "test",
"hostname": "test",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "///\\//\\//test",
"base": "http://example.org/",
"href": "http://test/",
"protocol": "http:",
"username": "",
"password": "",
"host": "test",
"hostname": "test",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "///example.org/path",
"base": "http://example.org/",
"href": "http://example.org/path",
"protocol": "http:",
"username": "",
"password": "",
"host": "example.org",
"hostname": "example.org",
"port": "",
"pathname": "/path",
"search": "",
"hash": ""
},
{
"input": "///example.org/../path",
"base": "http://example.org/",
"href": "http://example.org/path",
"protocol": "http:",
"username": "",
"password": "",
"host": "example.org",
"hostname": "example.org",
"port": "",
"pathname": "/path",
"search": "",
"hash": ""
},
{
"input": "///example.org/../../",
"base": "http://example.org/",
"href": "http://example.org/",
"protocol": "http:",
"username": "",
"password": "",
"host": "example.org",
"hostname": "example.org",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "///example.org/../path/../../",
"base": "http://example.org/",
"href": "http://example.org/",
"protocol": "http:",
"username": "",
"password": "",
"host": "example.org",
"hostname": "example.org",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "///example.org/../path/../../path",
"base": "http://example.org/",
"href": "http://example.org/path",
"protocol": "http:",
"username": "",
"password": "",
"host": "example.org",
"hostname": "example.org",
"port": "",
"pathname": "/path",
"search": "",
"hash": ""
},
{
"input": "/\\/\\//example.org/../path",
"base": "http://example.org/",
"href": "http://example.org/path",
"protocol": "http:",
"username": "",
"password": "",
"host": "example.org",
"hostname": "example.org",
"port": "",
"pathname": "/path",
"search": "",
"hash": ""
},
{
"input": "///abcdef/../",
"base": "file:///",
"href": "file:///",
"protocol": "file:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "/\\//\\/a/../",
"base": "file:///",
"href": "file://////",
"protocol": "file:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "////",
"search": "",
"hash": ""
},
{
"input": "//a/../",
"base": "file:///",
"href": "file://a/",
"protocol": "file:",
"username": "",
"password": "",
"host": "a",
"hostname": "a",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ PASS Parsing: <http://foo.com:b@d/> against <http://example.org/foo/bar>
PASS Parsing: <http://foo.com/\@> against <http://example.org/foo/bar>
PASS Parsing: <http:\\foo.com\> against <http://example.org/foo/bar>
PASS Parsing: <http:\\a\b:c\d@foo.com\> against <http://example.org/foo/bar>
PASS Parsing: <http://a:b@c\> without base
PASS Parsing: <ws://a@b\c> without base
PASS Parsing: <foo:/> against <http://example.org/foo/bar>
PASS Parsing: <foo:/bar.com/> against <http://example.org/foo/bar>
PASS Parsing: <foo://///////> against <http://example.org/foo/bar>
Expand Down Expand Up @@ -684,4 +686,12 @@ PASS Parsing: <stun://test:test> without base
PASS Parsing: <stun://[:1]> without base
PASS Parsing: <w://x:0> without base
PASS Parsing: <west://x:0> without base
PASS Parsing: <///test> against <http://example.org/>
PASS Parsing: <///\//\//test> against <http://example.org/>
PASS Parsing: <///example.org/path> against <http://example.org/>
PASS Parsing: <///example.org/../path> against <http://example.org/>
PASS Parsing: <///example.org/../../> against <http://example.org/>
PASS Parsing: <///example.org/../path/../../> against <http://example.org/>
PASS Parsing: <///example.org/../path/../../path> against <http://example.org/>
PASS Parsing: </\/\//example.org/../path> against <http://example.org/>

Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,7 @@ PASS Parsing: <file://­/p> without base
PASS Parsing: <file://%C2%AD/p> without base
PASS Parsing: <file://xn--/p> without base
PASS Parsing: <> without base
PASS Parsing: <///abcdef/../> against <file:///>
PASS Parsing: </\//\/a/../> against <file:///>
PASS Parsing: <//a/../> against <file:///>

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ PASS Parsing: <http://foo.com:b@d/> against <http://example.org/foo/bar>
PASS Parsing: <http://foo.com/\@> against <http://example.org/foo/bar>
PASS Parsing: <http:\\foo.com\> against <http://example.org/foo/bar>
PASS Parsing: <http:\\a\b:c\d@foo.com\> against <http://example.org/foo/bar>
PASS Parsing: <http://a:b@c\> without base
PASS Parsing: <ws://a@b\c> without base
PASS Parsing: <foo:/> against <http://example.org/foo/bar>
PASS Parsing: <foo:/bar.com/> against <http://example.org/foo/bar>
PASS Parsing: <foo://///////> against <http://example.org/foo/bar>
Expand Down Expand Up @@ -684,4 +686,12 @@ PASS Parsing: <stun://test:test> without base
PASS Parsing: <stun://[:1]> without base
PASS Parsing: <w://x:0> without base
PASS Parsing: <west://x:0> without base
PASS Parsing: <///test> against <http://example.org/>
PASS Parsing: <///\//\//test> against <http://example.org/>
PASS Parsing: <///example.org/path> against <http://example.org/>
PASS Parsing: <///example.org/../path> against <http://example.org/>
PASS Parsing: <///example.org/../../> against <http://example.org/>
PASS Parsing: <///example.org/../path/../../> against <http://example.org/>
PASS Parsing: <///example.org/../path/../../path> against <http://example.org/>
PASS Parsing: </\/\//example.org/../path> against <http://example.org/>

Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,7 @@ PASS Parsing: <file://­/p> without base
PASS Parsing: <file://%C2%AD/p> without base
PASS Parsing: <file://xn--/p> without base
PASS Parsing: <> without base
PASS Parsing: <///abcdef/../> against <file:///>
PASS Parsing: </\//\/a/../> against <file:///>
PASS Parsing: <//a/../> against <file:///>

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ PASS Origin parsing: <http://foo.com:b@d/> against <http://example.org/foo/bar>
PASS Origin parsing: <http://foo.com/\@> against <http://example.org/foo/bar>
PASS Origin parsing: <http:\\foo.com\> against <http://example.org/foo/bar>
PASS Origin parsing: <http:\\a\b:c\d@foo.com\> against <http://example.org/foo/bar>
PASS Origin parsing: <http://a:b@c\> without base
PASS Origin parsing: <ws://a@b\c> without base
PASS Origin parsing: <foo:/> against <http://example.org/foo/bar>
PASS Origin parsing: <foo:/bar.com/> against <http://example.org/foo/bar>
PASS Origin parsing: <foo://///////> against <http://example.org/foo/bar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ PASS Origin parsing: <http://foo.com:b@d/> against <http://example.org/foo/bar>
PASS Origin parsing: <http://foo.com/\@> against <http://example.org/foo/bar>
PASS Origin parsing: <http:\\foo.com\> against <http://example.org/foo/bar>
PASS Origin parsing: <http:\\a\b:c\d@foo.com\> against <http://example.org/foo/bar>
PASS Origin parsing: <http://a:b@c\> without base
PASS Origin parsing: <ws://a@b\c> without base
PASS Origin parsing: <foo:/> against <http://example.org/foo/bar>
PASS Origin parsing: <foo:/bar.com/> against <http://example.org/foo/bar>
PASS Origin parsing: <foo://///////> against <http://example.org/foo/bar>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

PASS URL.canParse(undefined, undefined)
PASS URL.canParse(a:b, undefined)
PASS URL.canParse(undefined, a:b)
PASS URL.canParse(a:/b, undefined)
PASS URL.canParse(undefined, a:/b)
PASS URL.canParse(aaa:b, undefined)
PASS URL.canParse(undefined, aaa:b)
PASS URL.canParse(aaa:/b, undefined)
PASS URL.canParse(undefined, aaa:/b)
PASS URL.canParse(https://test:test, undefined)
PASS URL.canParse(a, https://b/)

Loading

0 comments on commit 0264501

Please sign in to comment.