Open
Description
Creating an attribute from a (&[u8], &[u8])
performs no transformation (escaping) on the provided value, but creating an attribute from (&str, &str)
does.
This feels a bit too implicit. It should probably be treated like BytesText
instead, where different methods are provided depending on whether the value has been pre-escaped. https://docs.rs/quick-xml/latest/quick_xml/events/struct.BytesText.html
use quick_xml::events::attributes::Attribute;
fn main() {
// correct
println!("{:#?}", Attribute::from(("foo", "Bells & Whistles")));
println!("{:#?}", Attribute::from(("foo".as_bytes(), "Bells & Whistles".as_bytes())));
// incorrect
println!("{:#?}", Attribute::from(("foo", "Bells & Whistles")));
println!("{:#?}", Attribute::from(("foo".as_bytes(), "Bells & Whistles".as_bytes())));
}
Attribute { key: "foo", value: Owned("Bells & Whistles") }
Attribute { key: "foo", value: Borrowed("Bells & Whistles") }
Attribute { key: "foo", value: Owned("Bells & Whistles") }
Attribute { key: "foo", value: Borrowed("Bells & Whistles") }