Skip to content

Commit

Permalink
url: reject empty host after toAscii conversion
Browse files Browse the repository at this point in the history
Per the change in whatwg/url#497.
  • Loading branch information
djc committed Aug 18, 2020
1 parent 0a92c73 commit 6b05499
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/host.rs
Expand Up @@ -82,6 +82,9 @@ impl Host<String> {
}
let domain = percent_decode(input.as_bytes()).decode_utf8_lossy();
let domain = idna::domain_to_ascii(&domain)?;
if domain.is_empty() {
return Err(ParseError::EmptyHost);
}
if domain
.find(|c| {
matches!(
Expand Down
20 changes: 0 additions & 20 deletions tests/setters_tests.json
Expand Up @@ -950,16 +950,6 @@
"port": ""
}
},
{
"href": "file://hi/x",
"new_value": "",
"expected": {
"href": "file:///x",
"host": "",
"hostname": "",
"port": ""
}
},
{
"href": "sc://test@test/",
"new_value": "",
Expand Down Expand Up @@ -1284,16 +1274,6 @@
"port": ""
}
},
{
"href": "file://hi/x",
"new_value": "",
"expected": {
"href": "file:///x",
"host": "",
"hostname": "",
"port": ""
}
},
{
"href": "sc://test@test/",
"new_value": "",
Expand Down

0 comments on commit 6b05499

Please sign in to comment.