We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4f880c6 commit f0084e1Copy full SHA for f0084e1
lightning-block-sync/src/http.rs
@@ -348,9 +348,11 @@ impl HttpClient {
348
349
if !status.is_ok() {
350
// TODO: Handle 3xx redirection responses.
351
- let error_details = match contents.is_ascii() {
352
- true => String::from_utf8_lossy(&contents).to_string(),
353
- 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.
354
+ Ok(s) if s.as_bytes().iter().all(|c| c.is_ascii() && !c.is_ascii_control()) => s,
355
+ _ => "binary".to_string()
356
};
357
let error_msg = format!("Errored with status: {} and contents: {}",
358
status.code, error_details);
0 commit comments