From ffaf5e04b88cc8cf86d644b69ce0bca9de6f2581 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Mon, 17 Aug 2020 18:58:06 +0200 Subject: [PATCH] Do not unwrap on invalid utf8 in link checker Closes #1134 --- components/link_checker/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/link_checker/src/lib.rs b/components/link_checker/src/lib.rs index 5ed0935a..d4336bca 100644 --- a/components/link_checker/src/lib.rs +++ b/components/link_checker/src/lib.rs @@ -54,7 +54,10 @@ pub fn check_url(url: &str, config: &LinkChecker) -> Result { let body = { let mut buf: Vec = vec![]; response.copy_to(&mut buf).unwrap(); - String::from_utf8(buf).unwrap() + match String::from_utf8(buf) { + Ok(s) => s, + Err(_) => return Err("The page didn't return valid UTF-8".to_string()) + } }; match check_page_for_anchor(url, body) {