Skip to content

Commit 6b05499

Browse files
committed
url: reject empty host after toAscii conversion
Per the change in whatwg/url#497.
1 parent 0a92c73 commit 6b05499

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

src/host.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ impl Host<String> {
8282
}
8383
let domain = percent_decode(input.as_bytes()).decode_utf8_lossy();
8484
let domain = idna::domain_to_ascii(&domain)?;
85+
if domain.is_empty() {
86+
return Err(ParseError::EmptyHost);
87+
}
8588
if domain
8689
.find(|c| {
8790
matches!(

tests/setters_tests.json

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -950,16 +950,6 @@
950950
"port": ""
951951
}
952952
},
953-
{
954-
"href": "file://hi/x",
955-
"new_value": "",
956-
"expected": {
957-
"href": "file:///x",
958-
"host": "",
959-
"hostname": "",
960-
"port": ""
961-
}
962-
},
963953
{
964954
"href": "sc://test@test/",
965955
"new_value": "",
@@ -1284,16 +1274,6 @@
12841274
"port": ""
12851275
}
12861276
},
1287-
{
1288-
"href": "file://hi/x",
1289-
"new_value": "",
1290-
"expected": {
1291-
"href": "file:///x",
1292-
"host": "",
1293-
"hostname": "",
1294-
"port": ""
1295-
}
1296-
},
12971277
{
12981278
"href": "sc://test@test/",
12991279
"new_value": "",

0 commit comments

Comments
 (0)