Skip to content
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

Calling quirks::set_port() with invalid prefix characters unset the port (WPT non-compliance) #974

Closed
hansl opened this issue Sep 26, 2024 · 0 comments · Fixed by #975
Closed

Comments

@hansl
Copy link
Contributor

hansl commented Sep 26, 2024

In browsers (tested on Chrome, Firefox and Safari), doing the following:

const u = new URL("https://example.com:8000");
u.port = "\u00009000";
console.log(u.port);

will show port 8000 (unchanged). This is also tested in the WPT suite here: https://github.com/web-platform-tests/wpt/blob/2a64dae4641fbd61bd4257df460e188f425b492e/url/url-setters-stripping.any.js#L85-L91. That's how the bug came to my attention.

Doing the same using:

let mut url = url::Url::parse("http://example.com:8000").unwrap();
url::quirks::set_port(&mut url, "\u{0000}9000").unwrap();
assert_eq!(url.port(), Some(8000));

will panic with url.port() returning None.

github-merge-queue bot pushed a commit that referenced this issue Sep 30, 2024
* Add a test for issue 974

* Fix the issue

* rename test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant