Do not unwrap on invalid utf8 in link checker

Closes #1134
This commit is contained in:
Vincent Prouillet 2020-08-17 18:58:06 +02:00
parent 278cc82fc7
commit ffaf5e04b8

View file

@ -54,7 +54,10 @@ pub fn check_url(url: &str, config: &LinkChecker) -> Result {
let body = {
let mut buf: Vec<u8> = 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) {