diff --git a/crates/xml/src/value.rs b/crates/xml/src/value.rs index 3636da8..ac5dab2 100644 --- a/crates/xml/src/value.rs +++ b/crates/xml/src/value.rs @@ -74,12 +74,13 @@ impl XmlDeserialize for T { let mut buf = Vec::new(); loop { match reader.read_event_into(&mut buf)? { - Event::Text(text) => { + Event::Text(bytes_text) => { + let text = bytes_text.unescape()?; if !string.is_empty() { // Content already written return Err(XmlError::UnsupportedEvent("content already written")); } - string = String::from_utf8_lossy(text.as_ref()).to_string(); + string = text.to_string(); } Event::CData(cdata) => { let text = String::from_utf8(cdata.to_vec())?; diff --git a/crates/xml/tests/de_struct.rs b/crates/xml/tests/de_struct.rs index d281c62..bcc1a5d 100644 --- a/crates/xml/tests/de_struct.rs +++ b/crates/xml/tests/de_struct.rs @@ -265,6 +265,7 @@ fn test_xml_cdata() { #[xml(ty = "text")] hello: String, href: String, + okay: String, } let doc = Document::parse_str( @@ -272,6 +273,7 @@ fn test_xml_cdata() { + > "#, ) @@ -280,7 +282,8 @@ fn test_xml_cdata() { doc, Document { hello: "some text".to_owned(), - href: "some stuff".to_owned() + href: "some stuff".to_owned(), + okay: ">".to_owned() } ); }