Skip to content

Commit a08aa2c

Browse files
authored
Fix panic in set_path for file URLs (#865)
* Fix panic in set_path for file URLs * New minor version * Fix clippy lint
1 parent edabc79 commit a08aa2c

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

url/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name = "url"
44
# When updating version, also modify html_root_url in the lib.rs
5-
version = "2.4.0"
5+
version = "2.4.1"
66
authors = ["The rust-url developers"]
77

88
description = "URL library for Rust, based on the WHATWG URL Standard"

url/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ url = { version = "2", features = ["debugger_visualizer"] }
134134
135135
*/
136136

137-
#![doc(html_root_url = "https://docs.rs/url/2.4.0")]
137+
#![doc(html_root_url = "https://docs.rs/url/2.4.1")]
138138
#![cfg_attr(
139139
feature = "debugger_visualizer",
140140
debugger_visualizer(natvis_file = "../../debug_metadata/url.natvis")

url/src/parser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ impl<'a> Parser<'a> {
12021202
_ => {
12031203
self.check_url_code_point(c, &input);
12041204
if scheme_type.is_file()
1205+
&& self.serialization.len() > path_start
12051206
&& is_normalized_windows_drive_letter(
12061207
&self.serialization[path_start + 1..],
12071208
)

url/tests/unit.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn append_trailing_slash() {
472472
fn extend_query_pairs_then_mutate() {
473473
let mut url: Url = "http://localhost:6767/foo/bar".parse().unwrap();
474474
url.query_pairs_mut()
475-
.extend_pairs(vec![("auth", "my-token")].into_iter());
475+
.extend_pairs(vec![("auth", "my-token")]);
476476
url.check_invariants().unwrap();
477477
assert_eq!(
478478
url.to_string(),
@@ -1298,3 +1298,11 @@ fn test_file_with_drive_and_path() {
12981298
let url2 = url::Url::join(&url, s2).unwrap();
12991299
assert_eq!(url2.to_string(), "file:///p:/a");
13001300
}
1301+
1302+
#[test]
1303+
fn issue_864() {
1304+
let mut url = url::Url::parse("file://").unwrap();
1305+
dbg!(&url);
1306+
url.set_path("x");
1307+
dbg!(&url);
1308+
}

0 commit comments

Comments
 (0)