Skip to content

Commit 00a8727

Browse files
committed
1 parent 6805944 commit 00a8727

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/crates-io/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ impl Registry {
428428
// Headers contain trailing \r\n, trim them to make it easier
429429
// to work with.
430430
let s = String::from_utf8_lossy(data).trim().to_string();
431+
// Don't let server sneak extra lines anywhere.
432+
if s.contains('\n') {
433+
return true;
434+
}
431435
headers.push(s);
432436
true
433437
})?;
@@ -448,7 +452,11 @@ impl Registry {
448452

449453
match (self.handle.response_code()?, errors) {
450454
(0, None) | (200, None) => Ok(body),
451-
(code, Some(errors)) => Err(ResponseError::Api { code, headers, errors }),
455+
(code, Some(errors)) => Err(ResponseError::Api {
456+
code,
457+
headers,
458+
errors,
459+
}),
452460
(code, None) => Err(ResponseError::Code {
453461
code,
454462
headers,

0 commit comments

Comments
 (0)