From 9847084ad9051661873f3c5c5bf3c8dc83233ba3 Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Mon, 28 Aug 2023 10:29:37 +0200 Subject: [PATCH 1/3] Fix panic in set_path for file URLs --- url/src/parser.rs | 1 + url/tests/unit.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/url/src/parser.rs b/url/src/parser.rs index d5ae8314c..7d94d1d71 100644 --- a/url/src/parser.rs +++ b/url/src/parser.rs @@ -1202,6 +1202,7 @@ impl<'a> Parser<'a> { _ => { self.check_url_code_point(c, &input); if scheme_type.is_file() + && self.serialization.len() > path_start && is_normalized_windows_drive_letter( &self.serialization[path_start + 1..], ) diff --git a/url/tests/unit.rs b/url/tests/unit.rs index 6cb0f37fe..c13035491 100644 --- a/url/tests/unit.rs +++ b/url/tests/unit.rs @@ -1298,3 +1298,11 @@ fn test_file_with_drive_and_path() { let url2 = url::Url::join(&url, s2).unwrap(); assert_eq!(url2.to_string(), "file:///p:/a"); } + +#[test] +fn issue_864() { + let mut url = url::Url::parse("file://").unwrap(); + dbg!(&url); + url.set_path("x"); + dbg!(&url); +} From c54d5439f5bf018fc506612a29c467071407717b Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Mon, 28 Aug 2023 11:03:01 +0200 Subject: [PATCH 2/3] New minor version --- url/Cargo.toml | 2 +- url/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/url/Cargo.toml b/url/Cargo.toml index a9dfa16ef..969706d92 100644 --- a/url/Cargo.toml +++ b/url/Cargo.toml @@ -2,7 +2,7 @@ name = "url" # When updating version, also modify html_root_url in the lib.rs -version = "2.4.0" +version = "2.4.1" authors = ["The rust-url developers"] description = "URL library for Rust, based on the WHATWG URL Standard" diff --git a/url/src/lib.rs b/url/src/lib.rs index 3f2788cf2..58c7c07cd 100644 --- a/url/src/lib.rs +++ b/url/src/lib.rs @@ -134,7 +134,7 @@ url = { version = "2", features = ["debugger_visualizer"] } */ -#![doc(html_root_url = "https://docs.rs/url/2.4.0")] +#![doc(html_root_url = "https://docs.rs/url/2.4.1")] #![cfg_attr( feature = "debugger_visualizer", debugger_visualizer(natvis_file = "../../debug_metadata/url.natvis") From e9b761bfb1ace4a8426e13a7d5178ba875c5d023 Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Mon, 28 Aug 2023 11:06:46 +0200 Subject: [PATCH 3/3] Fix clippy lint --- url/tests/unit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/url/tests/unit.rs b/url/tests/unit.rs index c13035491..c27f237ba 100644 --- a/url/tests/unit.rs +++ b/url/tests/unit.rs @@ -472,7 +472,7 @@ fn append_trailing_slash() { fn extend_query_pairs_then_mutate() { let mut url: Url = "http://localhost:6767/foo/bar".parse().unwrap(); url.query_pairs_mut() - .extend_pairs(vec![("auth", "my-token")].into_iter()); + .extend_pairs(vec![("auth", "my-token")]); url.check_invariants().unwrap(); assert_eq!( url.to_string(),