Return input if decode_entities() encounters error

This commit is contained in:
RumovZ 2021-03-22 12:08:22 +01:00
parent a6fb72780a
commit 9151bfb53e

View file

@ -138,10 +138,9 @@ pub fn strip_html_preserving_entities(html: &str) -> Cow<str> {
pub fn decode_entities(html: &str) -> Cow<str> {
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()