-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-special URLs were not idempotent #505
Conversation
Adjust the URL serializer so it does not output something which during the next parse operation would yield a host. whatwg-url: ... Tests: ... Fixes #415.
9a50c7a
to
c3c7a82
Compare
See whatwg/url#415 and whatwg/url#505 for context.
Tests: web-platform-tests/wpt#25113 |
Tests reviewed; shall we land this? |
@domenic is Chrome interested? I'm checking with Valentin if Mozilla is and also pinged WebKit's representative again. |
I think I can confidently say that Chrome has as a long-term goal reasonable, interoperable URL parsing, and this change is part of that. So yeah, +1 from Chrome. |
Added Node.js to list of implementation bugs to file, per #525. |
See whatwg/url#415 and whatwg/url#505 for context.
Thanks all! I updated OP to include the relevant information. |
…testonly Automatic update from web-platform-tests Test non-special URLs are idempotent See whatwg/url#415 and whatwg/url#505 for context. -- wpt-commits: 551c9d604fb8b97d3f8c65793bb047d15baddbc2 wpt-pr: 25113
Fixes: nodejs#34899 Refs: whatwg/url#505 Refs: web-platform-tests/wpt#25113
Fixes: #34899 Refs: whatwg/url#505 Refs: web-platform-tests/wpt#25113 PR-URL: #34925 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
…testonly Automatic update from web-platform-tests Test non-special URLs are idempotent See whatwg/url#415 and whatwg/url#505 for context. -- wpt-commits: 551c9d604fb8b97d3f8c65793bb047d15baddbc2 wpt-pr: 25113
https://bugs.webkit.org/show_bug.cgi?id=215762 Reviewed by Tim Horton. LayoutTests/imported/w3c: * web-platform-tests/url/a-element-expected.txt: * web-platform-tests/url/a-element-xhtml-expected.txt: * web-platform-tests/url/url-constructor-expected.txt: * web-platform-tests/url/url-setters-expected.txt: Source/WTF: whatwg/url#505 added an interesting edge case to the URL serialization: "If url’s host is null, url’s path’s size is greater than 1, and url’s path[0] is the empty string, then append U+002F (/) followed by U+002E (.) to output." The problem was that URLs like "a:/a/..//a" would be parsed into "a://a" with a pathname of "//a" and an empty host. If "a://a" was then reparsed, it would again have an href of "a://a" but its host would be "a" and it would have an empty path. There is consensus that URL parsing should be idempotent, so we need to do something different here. According to whatwg/url#415 (comment) this follows what Edge did (and then subsequently abandoned when they switched to Chromium) to make URL parsing idempotent by adding "/." before the path in the edge case of a URL with a non-special scheme (not http, https, wss, etc.) and a null host and a non-empty path that has an empty first segment. All the members of the URL remain unchanged except the full serialization (href). This is not important in practice, but important in theory. Our URL parser tries very hard to use the exact same WTF::String object given as input if it can. However, this step is better implemented as a post-processing step that will almost never happen because otherwise we would have to parse the entire path twice to find out if we need to add "./" or if the "./" that may have already been there needs to stay. This is illustrated with the test URL "t:/.//p/../../../..//x" which does need the "./". In the common case, this adds one well-predicted branch to URL parsing, so I expect performance to be unaffected. Since this is such a rare edge case of URLs, I expect no compatibility problems. * wtf/URL.cpp: (WTF::URL::pathStart const): * wtf/URL.h: (WTF::URL::pathStart const): Deleted. * wtf/URLParser.cpp: (WTF::URLParser::copyURLPartsUntil): (WTF::URLParser::URLParser): (WTF::URLParser::needsNonSpecialDotSlash const): (WTF::URLParser::addNonSpecialDotSlash): * wtf/URLParser.h: Tools: * TestWebKitAPI/Tests/WTF/URLParser.cpp: (TestWebKitAPI::TEST_F): Canonical link: https://commits.webkit.org/229956@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fixes: nodejs#34899 Refs: whatwg/url#505 Refs: web-platform-tests/wpt#25113 PR-URL: nodejs#34925 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Adjust the URL serializer so it does not output something which during the next parse operation would yield a host.
whatwg-url: jsdom/whatwg-url#148
Tests: ...
Fixes #415.
@zealousidealroll what do you think?
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff