From 9151bfb53e75fa2f3a44ff46e17704894ab22476 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Mon, 22 Mar 2021 12:08:22 +0100 Subject: [PATCH] Return input if decode_entities() encounters error --- rslib/src/text.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rslib/src/text.rs b/rslib/src/text.rs index 85a713539..7af9635a1 100644 --- a/rslib/src/text.rs +++ b/rslib/src/text.rs @@ -138,10 +138,9 @@ pub fn strip_html_preserving_entities(html: &str) -> Cow { pub fn decode_entities(html: &str) -> Cow { if html.contains('&') { match htmlescape::decode_html(html) { - Ok(text) => text.replace('\u{a0}', " "), - Err(e) => format!("{:?}", e), + Ok(text) => text.replace('\u{a0}', " ").into(), + Err(_) => html.into(), } - .into() } else { // nothing to do html.into()