diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-04-09 18:00:27 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-04-09 18:00:27 +0300 |
commit | dcfe3205408ee8a23e7821f80bf81070755ceb99 (patch) | |
tree | 456e4817bd9a9fd62531d9c70a7af7ee66380d0a | |
parent | d45c2bc8b797a906cb630d322fb32f4f5a2f0699 (diff) | |
download | html-page-dcfe3205408ee8a23e7821f80bf81070755ceb99.tar.gz |
fix: quote attribute values
Sponsored-by: author
-rw-r--r-- | src/lib.rs | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -360,7 +360,7 @@ impl Display for Attributes { match value { AttributeValue::Boolean => write!(f, " {}", name)?, AttributeValue::String(s) => { - write!(f, " {}={}", name, encode_double_quoted_attribute(s))? + write!(f, " {}=\"{}\"", name, encode_double_quoted_attribute(s))? } } } @@ -681,14 +681,14 @@ mod test { fn attribute_can_be_serialized() { let mut e = Element::new(Tag::P); e.set_attribute("foo", "bar"); - assert_eq!(e.serialize(), "<P foo=bar/>"); + assert_eq!(e.serialize(), "<P foo=\"bar\"/>"); } #[test] fn dangerous_attribute_value_is_esacped() { let mut e = Element::new(Tag::P); e.set_attribute("foo", "<"); - assert_eq!(e.serialize(), "<P foo=</>"); + assert_eq!(e.serialize(), "<P foo=\"<\"/>"); } #[test] |