Skip to content

Commit

Permalink
Fix panic in set_path for file URLs (#865)
Browse files Browse the repository at this point in the history
* Fix panic in set_path for file URLs

* New minor version

* Fix clippy lint
  • Loading branch information
valenting authored Aug 28, 2023
1 parent edabc79 commit a08aa2c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion url/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion url/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions url/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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..],
)
Expand Down
10 changes: 9 additions & 1 deletion url/tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
}

0 comments on commit a08aa2c

Please sign in to comment.