to_text_xml: fix attribute escaping

This commit is contained in:
Matt Bilker
2019-02-08 06:39:26 +00:00
parent 05c70d8cb1
commit de253ef9c4
2 changed files with 6 additions and 3 deletions

View File

@@ -53,9 +53,11 @@ impl ToTextXml for Node {
if let Some(attributes) = self.attributes() {
for (key, value) in attributes {
let value = BytesText::from_plain_str(&value);
elem.push_attribute(Attribute {
key: key.as_bytes(),
value: Cow::Borrowed(value.as_bytes()),
value: Cow::Borrowed(value.escaped()),
});
}
}

View File

@@ -61,11 +61,12 @@ impl ToTextXml for NodeCollection {
for attribute in self.attributes() {
let key = attribute.key()?.ok_or(KbinErrorKind::InvalidState)?.into_bytes();
let value = attribute.value()?.to_string().into_bytes();
let value = attribute.value()?.to_string();
let value = BytesText::from_plain_str(&value);
elem.push_attribute(Attribute {
key: &key,
value: Cow::Owned(value),
value: Cow::Borrowed(value.escaped()),
});
}