Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lightning-block-sync/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,11 @@ impl HttpClient {

if !status.is_ok() {
// TODO: Handle 3xx redirection responses.
let error_details = match contents.is_ascii() {
true => String::from_utf8_lossy(&contents).to_string(),
false => "binary".to_string()
let error_details = match String::from_utf8(contents) {
// Check that the string is all-ASCII with no control characters before returning
// it.
Ok(s) if s.as_bytes().iter().all(|c| c.is_ascii() && !c.is_ascii_control()) => s,
_ => "binary".to_string()
};
let error_msg = format!("Errored with status: {} and contents: {}",
status.code, error_details);
Expand Down