Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions url/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,11 @@ impl<'a> Parser<'a> {
}
input = remaining;
}

if !has_any_digit && context == Context::Setter && !input.is_empty() {
return Err(ParseError::InvalidPort);
}

let mut opt_port = Some(port as u16);
if !has_any_digit || opt_port == default_port() {
opt_port = None;
Expand Down
1 change: 0 additions & 1 deletion url/tests/expected_failures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<non-spec:/.//p> set hostname to <h>
<non-spec:/.//p> set hostname to <>
<foo:///some/path> set pathname to <>
<http://example.net:8080/path> set port to <randomstring>
<file:///var/log/system.log> set href to <http://0300.168.0xF0>
<file://monkey/> set pathname to <\\\\>
<file:///unicorn> set pathname to <//\\/>
Expand Down
7 changes: 7 additions & 0 deletions url/tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,3 +1316,10 @@ fn issue_864() {
url.set_path("x");
dbg!(&url);
}

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