Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in set_path for file URLs #865

Merged
merged 3 commits into from Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion url/Cargo.toml
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
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
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
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);
}