Skip to content

Commit bf825dc

Browse files
committed
Test HTTP header encoding and syntax
1 parent 39398fb commit bf825dc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crates/cargo-test-support/src/registry.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,10 @@ impl HttpServer {
794794
line.clear();
795795
break;
796796
}
797-
let (name, value) = line.split_once(':').unwrap();
797+
if line.as_bytes().iter().any(|&b| b > 127 || b == 0) {
798+
panic!("Invalid char in HTTP header: {line:?}");
799+
}
800+
let (name, value) = line.split_once(':').expect("http header syntax");
798801
let name = name.trim().to_ascii_lowercase();
799802
let value = value.trim().to_string();
800803
match name.as_str() {

0 commit comments

Comments
 (0)