From de253ef9c49fd127935c92d871e436b1b12e0e53 Mon Sep 17 00:00:00 2001 From: Matt Bilker Date: Fri, 8 Feb 2019 06:39:26 +0000 Subject: [PATCH] to_text_xml: fix attribute escaping --- src/to_text_xml/node.rs | 4 +++- src/to_text_xml/node_collection.rs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/to_text_xml/node.rs b/src/to_text_xml/node.rs index ec1fccb..535c0a9 100644 --- a/src/to_text_xml/node.rs +++ b/src/to_text_xml/node.rs @@ -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()), }); } } diff --git a/src/to_text_xml/node_collection.rs b/src/to_text_xml/node_collection.rs index 30b7b24..e5126ce 100644 --- a/src/to_text_xml/node_collection.rs +++ b/src/to_text_xml/node_collection.rs @@ -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()), }); }