From 13f1da927c990a3670bc16274efc1e6c4e7d1145 Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Wed, 9 Aug 2023 11:36:55 -0500 Subject: [PATCH] Fix an issue where enabling HTTP debugging may attempt to slice a string across a character boundry resulting in a panic --- src/cargo/util/network/http.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cargo/util/network/http.rs b/src/cargo/util/network/http.rs index e5e429611f7..73880f60e16 100644 --- a/src/cargo/util/network/http.rs +++ b/src/cargo/util/network/http.rs @@ -152,6 +152,8 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult< _ => return, }; let starts_with_ignore_case = |line: &str, text: &str| -> bool { + let line = line.as_bytes(); + let text = text.as_bytes(); line[..line.len().min(text.len())].eq_ignore_ascii_case(text) }; match str::from_utf8(data) {