Bug 265484 - URLParser should parse URLs including authority and a backslash after the host
Summary: URLParser should parse URLs including authority and a backslash after the host
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Trivial
Assignee: Anne van Kesteren
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2023-11-28 15:30 PST by dave caruso
Modified: 2024-02-17 07:06 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dave caruso 2023-11-28 15:30:43 PST
WTF:URLParser is unable to parse the text `
`, specifically due to the backslash.

In Safari/JSC you can run `new URL` with this string to see an error. Chrome/firefox/node.js all allow parsing this url.

The specification defines one case in host state (https://url.spec.whatwg.org/#host-state) where backslash is allowed when using special urls.

WTF::URLParser::parse does not seem to handle that. I suspect this is a one line fix around line 1486, but I have not tested the patch.

- if (*c == '/' || *c == '?' || *c == '#') {
+ if (*c == '/' || (m_urlIsSpecial && *c == '\\') || *c == '?' || *c == '#') {
Comment 1 Karl Dubost 2023-11-28 17:59:00 PST
Dave, thanks for the report.
Is there a missing string in the bug report?

> the text `
> `,
Comment 2 dave caruso 2023-11-28 18:12:06 PST
Yes it seems the url may have been auto-redacted due to it containing authorization.

"http:// a : b @ c \ hello"

i've rewritten the url with spaces. it is any "special" (protocol http/https/file and some others) but there is a backslash instead of a forward slash after the host and starting the path name. the url can also have no path but end in a backslash.
Comment 4 Alex Christensen 2023-11-29 09:31:57 PST
I think you're right, Dave.  Would you like to make a PR or two, or would you like me to?  Either way it should have a test with a special scheme and a test with a non-special scheme.  Our tests for this are in LayoutTests/imported/w3c/web-platform-tests/url/resources/urltestdata.json and ideally it would have a PR to the WPT repo as well.
Comment 5 dave caruso 2023-11-29 11:05:09 PST
I can work on a PR this weekend. Thanks for pointing me to the tests.
Comment 6 Alex Christensen 2023-11-29 11:14:49 PST
Sounds good!  Let's just make a WebKit PR for now.  WPT will be updated with this in due time.

This command will help in updating the test results:
Tools/Scripts/run-webkit-tests imported/w3c/web-platform-tests/url --reset --no-build
Comment 7 Radar WebKit Bug Importer 2023-12-05 15:31:12 PST
<rdar://problem/119219832>
Comment 8 Anne van Kesteren 2024-02-16 15:08:11 PST
Pull request: https://github.com/WebKit/WebKit/pull/24657
Comment 9 EWS 2024-02-17 07:06:28 PST
Committed 274915@main (953476de5074): <https://commits.webkit.org/274915@main>

Reviewed commits have been landed. Closing PR #24657 and removing active labels.