mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
xml: Fix unescaping for String values
This commit is contained in:
@@ -74,12 +74,13 @@ impl<T: ValueDeserialize> XmlDeserialize for T {
|
|||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
match reader.read_event_into(&mut buf)? {
|
match reader.read_event_into(&mut buf)? {
|
||||||
Event::Text(text) => {
|
Event::Text(bytes_text) => {
|
||||||
|
let text = bytes_text.unescape()?;
|
||||||
if !string.is_empty() {
|
if !string.is_empty() {
|
||||||
// Content already written
|
// Content already written
|
||||||
return Err(XmlError::UnsupportedEvent("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) => {
|
Event::CData(cdata) => {
|
||||||
let text = String::from_utf8(cdata.to_vec())?;
|
let text = String::from_utf8(cdata.to_vec())?;
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ fn test_xml_cdata() {
|
|||||||
#[xml(ty = "text")]
|
#[xml(ty = "text")]
|
||||||
hello: String,
|
hello: String,
|
||||||
href: String,
|
href: String,
|
||||||
|
okay: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
let doc = Document::parse_str(
|
let doc = Document::parse_str(
|
||||||
@@ -272,6 +273,7 @@ fn test_xml_cdata() {
|
|||||||
<document>
|
<document>
|
||||||
<![CDATA[some text]]>
|
<![CDATA[some text]]>
|
||||||
<href><![CDATA[some stuff]]></href>
|
<href><![CDATA[some stuff]]></href>
|
||||||
|
<okay>></okay>
|
||||||
</document>
|
</document>
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
@@ -280,7 +282,8 @@ fn test_xml_cdata() {
|
|||||||
doc,
|
doc,
|
||||||
Document {
|
Document {
|
||||||
hello: "some text".to_owned(),
|
hello: "some text".to_owned(),
|
||||||
href: "some stuff".to_owned()
|
href: "some stuff".to_owned(),
|
||||||
|
okay: ">".to_owned()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user