Skip to content

Commit

Permalink
Copy host from base file URL
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=217170

Reviewed by Brady Eidson.

LayoutTests/imported/w3c:

* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/resources/urltestdata.json:
* web-platform-tests/url/url-constructor-expected.txt:

Source/WTF:

This matches Chrome and the URL specification.
Covered by newly passing web platform tests.

I also updated the web platform tests from web-platform-tests/wpt#25716
which aligns with Safari in cases except copying of the host from base file URLs.

The implementation pushes copying from the base URL downstream in the parsing process to where it is in the URL specification
so that we can properly decide how much of the base URL to copy and so we can copy it into the right place in the result URL.

I also updated an assertion that makes sure that we re-use the input String if possible because there are cases where we copy
part of the parent URL, which is a "syntax violation" (meaning we copy the string parts and assemble a new one), then re-assemble
a new String that is equal to the input string.  This is not a problem, it just needed to be reflected in the assertion.

* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::parse):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@267896 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
[email protected] committed Oct 2, 2020
1 parent ea87d23 commit 976e8d9
Show file tree
Hide file tree
Showing 7 changed files with 410 additions and 140 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/imported/w3c/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2020-10-02 Alex Christensen <[email protected]>

Copy host from base file URL
https://bugs.webkit.org/show_bug.cgi?id=217170

Reviewed by Brady Eidson.

* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/resources/urltestdata.json:
* web-platform-tests/url/url-constructor-expected.txt:

2020-10-02 Sam Weinig <[email protected]>

Re-align HTMLElement with the HTML spec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ PASS Parsing: <pix/submit.gif> against <file:///C:/Users/Domenic/Dropbox/GitHub/
PASS Parsing: <..> against <file:///C:/>
PASS Parsing: <..> against <file:///>
PASS Parsing: </> against <file:///C:/a/b>
PASS Parsing: </> against <file://h/C:/a/b>
PASS Parsing: </> against <file://h/a/b>
PASS Parsing: <//d:> against <file:///C:/a/b>
PASS Parsing: <//d:/..> against <file:///C:/a/b>
PASS Parsing: <..> against <file:///ab:/>
Expand All @@ -427,24 +429,24 @@ PASS Parsing: <?x> against <file:///test?test#test>
PASS Parsing: <file:?x> against <file:///test?test#test>
PASS Parsing: <#x> against <file:///test?test#test>
PASS Parsing: <file:#x> against <file:///test?test#test>
FAIL Parsing: <file:\\//> against <about:blank> assert_equals: href expected "file:///" but got "file:////"
FAIL Parsing: <file:\\\\> against <about:blank> assert_equals: href expected "file:///" but got "file:////"
FAIL Parsing: <file:\\\\?fox> against <about:blank> assert_equals: href expected "file:///?fox" but got "file:////?fox"
FAIL Parsing: <file:\\\\#guppy> against <about:blank> assert_equals: href expected "file:///#guppy" but got "file:////#guppy"
FAIL Parsing: <file://spider///> against <about:blank> assert_equals: href expected "file://spider/" but got "file://spider///"
FAIL Parsing: <file:\\localhost//> against <about:blank> assert_equals: href expected "file:///" but got "file:////"
PASS Parsing: <file:\\//> against <about:blank>
PASS Parsing: <file:\\\\> against <about:blank>
PASS Parsing: <file:\\\\?fox> against <about:blank>
PASS Parsing: <file:\\\\#guppy> against <about:blank>
PASS Parsing: <file://spider///> against <about:blank>
PASS Parsing: <file:\\localhost//> against <about:blank>
PASS Parsing: <file:///localhost//cat> against <about:blank>
FAIL Parsing: <file://\/localhost//cat> against <about:blank> assert_equals: href expected "file:///localhost//cat" but got "file:////localhost//cat"
FAIL Parsing: <file://localhost//a//../..//> against <about:blank> assert_equals: href expected "file:///" but got "file://///"
FAIL Parsing: </////mouse> against <file:///elephant> assert_equals: href expected "file:///mouse" but got "file://///mouse"
PASS Parsing: <file://\/localhost//cat> against <about:blank>
PASS Parsing: <file://localhost//a//../..//> against <about:blank>
PASS Parsing: </////mouse> against <file:///elephant>
PASS Parsing: <\//pig> against <file://lion/>
FAIL Parsing: <\/localhost//pig> against <file://lion/> assert_equals: href expected "file:///pig" but got "file:////pig"
FAIL Parsing: <//localhost//pig> against <file://lion/> assert_equals: href expected "file:///pig" but got "file:////pig"
FAIL Parsing: </..//localhost//pig> against <file://lion/> assert_equals: href expected "file://lion/localhost//pig" but got "file:////localhost//pig"
PASS Parsing: <\/localhost//pig> against <file://lion/>
PASS Parsing: <//localhost//pig> against <file://lion/>
PASS Parsing: </..//localhost//pig> against <file://lion/>
PASS Parsing: <file://> against <file://ape/>
FAIL Parsing: </rooibos> against <file://tea/> assert_equals: href expected "file://tea/rooibos" but got "file:///rooibos"
FAIL Parsing: </?chai> against <file://tea/> assert_equals: href expected "file://tea/?chai" but got "file:///?chai"
FAIL Parsing: <C|> against <file://host/dir/file> assert_equals: href expected "file:///C:" but got "file://host/dir/C|"
PASS Parsing: </rooibos> against <file://tea/>
PASS Parsing: </?chai> against <file://tea/>
FAIL Parsing: <C|> against <file://host/dir/file> assert_equals: href expected "file://host/C:" but got "file://host/dir/C|"
PASS Parsing: <C|#> against <file://host/dir/file>
PASS Parsing: <C|?> against <file://host/dir/file>
PASS Parsing: <C|/> against <file://host/dir/file>
Expand All @@ -457,9 +459,9 @@ PASS Parsing: </c:/foo/bar> against <file:///c:/baz/qux>
PASS Parsing: </c|/foo/bar> against <file:///c:/baz/qux>
PASS Parsing: <file:\c:\foo\bar> against <file:///c:/baz/qux>
PASS Parsing: </c:/foo/bar> against <file://host/path>
FAIL Parsing: <file://example.net/C:/> against <about:blank> assert_equals: href expected "file:///C:/" but got "file://example.net/C:/"
FAIL Parsing: <file://1.2.3.4/C:/> against <about:blank> assert_equals: href expected "file:///C:/" but got "file://1.2.3.4/C:/"
FAIL Parsing: <file://[1::8]/C:/> against <about:blank> assert_equals: href expected "file:///C:/" but got "file://[1::8]/C:/"
PASS Parsing: <file://example.net/C:/> against <about:blank>
PASS Parsing: <file://1.2.3.4/C:/> against <about:blank>
PASS Parsing: <file://[1::8]/C:/> against <about:blank>
PASS Parsing: <file:/C|/> against <about:blank>
PASS Parsing: <file://C|/> against <about:blank>
PASS Parsing: <file:> against <about:blank>
Expand All @@ -475,6 +477,15 @@ PASS Parsing: <file:///y:/> against <about:blank>
PASS Parsing: <file:///./y> against <about:blank>
PASS Parsing: <file:///./y:> against <about:blank>
PASS Parsing: <\\\.\y:> against <about:blank>
PASS Parsing: <file://localhost//a//../..//foo> against <about:blank>
PASS Parsing: <file://localhost////foo> against <about:blank>
PASS Parsing: <file:////foo> against <about:blank>
PASS Parsing: <file:///one/two> against <file:///>
PASS Parsing: <file:////one/two> against <file:///>
PASS Parsing: <//one/two> against <file:///>
PASS Parsing: <///one/two> against <file:///>
PASS Parsing: <////one/two> against <file:///>
PASS Parsing: <file:///.//> against <file:////>
PASS Parsing: <http://[1:0::]> against <http://example.net/>
PASS Parsing: <http://[0:1:2:3:4:5:6:7:8]> against <http://example.net/>
PASS Parsing: <https://[0::0::0]> against <about:blank>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ PASS Parsing: <pix/submit.gif> against <file:///C:/Users/Domenic/Dropbox/GitHub/
PASS Parsing: <..> against <file:///C:/>
PASS Parsing: <..> against <file:///>
PASS Parsing: </> against <file:///C:/a/b>
PASS Parsing: </> against <file://h/C:/a/b>
PASS Parsing: </> against <file://h/a/b>
PASS Parsing: <//d:> against <file:///C:/a/b>
PASS Parsing: <//d:/..> against <file:///C:/a/b>
PASS Parsing: <..> against <file:///ab:/>
Expand All @@ -427,24 +429,24 @@ PASS Parsing: <?x> against <file:///test?test#test>
PASS Parsing: <file:?x> against <file:///test?test#test>
PASS Parsing: <#x> against <file:///test?test#test>
PASS Parsing: <file:#x> against <file:///test?test#test>
FAIL Parsing: <file:\\//> against <about:blank> assert_equals: href expected "file:///" but got "file:////"
FAIL Parsing: <file:\\\\> against <about:blank> assert_equals: href expected "file:///" but got "file:////"
FAIL Parsing: <file:\\\\?fox> against <about:blank> assert_equals: href expected "file:///?fox" but got "file:////?fox"
FAIL Parsing: <file:\\\\#guppy> against <about:blank> assert_equals: href expected "file:///#guppy" but got "file:////#guppy"
FAIL Parsing: <file://spider///> against <about:blank> assert_equals: href expected "file://spider/" but got "file://spider///"
FAIL Parsing: <file:\\localhost//> against <about:blank> assert_equals: href expected "file:///" but got "file:////"
PASS Parsing: <file:\\//> against <about:blank>
PASS Parsing: <file:\\\\> against <about:blank>
PASS Parsing: <file:\\\\?fox> against <about:blank>
PASS Parsing: <file:\\\\#guppy> against <about:blank>
PASS Parsing: <file://spider///> against <about:blank>
PASS Parsing: <file:\\localhost//> against <about:blank>
PASS Parsing: <file:///localhost//cat> against <about:blank>
FAIL Parsing: <file://\/localhost//cat> against <about:blank> assert_equals: href expected "file:///localhost//cat" but got "file:////localhost//cat"
FAIL Parsing: <file://localhost//a//../..//> against <about:blank> assert_equals: href expected "file:///" but got "file://///"
FAIL Parsing: </////mouse> against <file:///elephant> assert_equals: href expected "file:///mouse" but got "file://///mouse"
PASS Parsing: <file://\/localhost//cat> against <about:blank>
PASS Parsing: <file://localhost//a//../..//> against <about:blank>
PASS Parsing: </////mouse> against <file:///elephant>
PASS Parsing: <\//pig> against <file://lion/>
FAIL Parsing: <\/localhost//pig> against <file://lion/> assert_equals: href expected "file:///pig" but got "file:////pig"
FAIL Parsing: <//localhost//pig> against <file://lion/> assert_equals: href expected "file:///pig" but got "file:////pig"
FAIL Parsing: </..//localhost//pig> against <file://lion/> assert_equals: href expected "file://lion/localhost//pig" but got "file:////localhost//pig"
PASS Parsing: <\/localhost//pig> against <file://lion/>
PASS Parsing: <//localhost//pig> against <file://lion/>
PASS Parsing: </..//localhost//pig> against <file://lion/>
PASS Parsing: <file://> against <file://ape/>
FAIL Parsing: </rooibos> against <file://tea/> assert_equals: href expected "file://tea/rooibos" but got "file:///rooibos"
FAIL Parsing: </?chai> against <file://tea/> assert_equals: href expected "file://tea/?chai" but got "file:///?chai"
FAIL Parsing: <C|> against <file://host/dir/file> assert_equals: href expected "file:///C:" but got "file://host/dir/C|"
PASS Parsing: </rooibos> against <file://tea/>
PASS Parsing: </?chai> against <file://tea/>
FAIL Parsing: <C|> against <file://host/dir/file> assert_equals: href expected "file://host/C:" but got "file://host/dir/C|"
PASS Parsing: <C|#> against <file://host/dir/file>
PASS Parsing: <C|?> against <file://host/dir/file>
PASS Parsing: <C|/> against <file://host/dir/file>
Expand All @@ -457,9 +459,9 @@ PASS Parsing: </c:/foo/bar> against <file:///c:/baz/qux>
PASS Parsing: </c|/foo/bar> against <file:///c:/baz/qux>
PASS Parsing: <file:\c:\foo\bar> against <file:///c:/baz/qux>
PASS Parsing: </c:/foo/bar> against <file://host/path>
FAIL Parsing: <file://example.net/C:/> against <about:blank> assert_equals: href expected "file:///C:/" but got "file://example.net/C:/"
FAIL Parsing: <file://1.2.3.4/C:/> against <about:blank> assert_equals: href expected "file:///C:/" but got "file://1.2.3.4/C:/"
FAIL Parsing: <file://[1::8]/C:/> against <about:blank> assert_equals: href expected "file:///C:/" but got "file://[1::8]/C:/"
PASS Parsing: <file://example.net/C:/> against <about:blank>
PASS Parsing: <file://1.2.3.4/C:/> against <about:blank>
PASS Parsing: <file://[1::8]/C:/> against <about:blank>
PASS Parsing: <file:/C|/> against <about:blank>
PASS Parsing: <file://C|/> against <about:blank>
PASS Parsing: <file:> against <about:blank>
Expand All @@ -475,6 +477,15 @@ PASS Parsing: <file:///y:/> against <about:blank>
PASS Parsing: <file:///./y> against <about:blank>
PASS Parsing: <file:///./y:> against <about:blank>
PASS Parsing: <\\\.\y:> against <about:blank>
PASS Parsing: <file://localhost//a//../..//foo> against <about:blank>
PASS Parsing: <file://localhost////foo> against <about:blank>
PASS Parsing: <file:////foo> against <about:blank>
PASS Parsing: <file:///one/two> against <file:///>
PASS Parsing: <file:////one/two> against <file:///>
PASS Parsing: <//one/two> against <file:///>
PASS Parsing: <///one/two> against <file:///>
PASS Parsing: <////one/two> against <file:///>
PASS Parsing: <file:///.//> against <file:////>
PASS Parsing: <http://[1:0::]> against <http://example.net/>
PASS Parsing: <http://[0:1:2:3:4:5:6:7:8]> against <http://example.net/>
PASS Parsing: <https://[0::0::0]> against <about:blank>
Expand Down
Loading

0 comments on commit 976e8d9

Please sign in to comment.