Skip to content

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

Closed
@hansl

Description

@hansl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions