From 49b9b754ffee693045ce3650be9eb21f7fae22cc Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 26 Feb 2023 22:00:53 +0100 Subject: fix: unescape XML text --- src/xml/parser.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/xml/parser.rs b/src/xml/parser.rs index 9cdafb1..bc8240c 100644 --- a/src/xml/parser.rs +++ b/src/xml/parser.rs @@ -1,5 +1,6 @@ use std::io::BufRead; +use quick_xml::escape::unescape; use quick_xml::events::attributes::AttrError; use quick_xml::events::{BytesStart, BytesText, Event}; use quick_xml::Reader; @@ -48,7 +49,13 @@ impl Parser fn parse_text(text: &BytesText) -> Result { - String::from_utf8(text.to_vec()).map_err(|_| Error::TextNotUTF8) + let text_escaped = + String::from_utf8(text.to_vec()).map_err(|_| Error::TextNotUTF8)?; + + let text_unescaped = unescape(&text_escaped) + .map_err(|err| Error::QuickXMLFailed(quick_xml::Error::EscapeError(err)))?; + + Ok(text_unescaped.to_string()) } fn parse_tagged(&mut self, start: &BytesStart) -> Result -- cgit v1.2.3-18-g5258