lol-html
lol-html copied to clipboard
HTML Entities are not Decoded in Attributes.
trafficstars
#[test]
fn test() {
lol_html::rewrite_str(
r#"
<img alt="Foo & Bar" src=example.png>
"#,
lol_html::RewriteStrSettings {
element_content_handlers: vec![
lol_html::element!("img", |e| {
assert_eq!(e.get_attribute("alt").as_deref(), Some("Foo & Bar"));
Ok(())
}),
],
..Default::default()
}).unwrap();
}
thread 'test' panicked at 'assertion failed: `(left == right)`
left: `Some("Foo & Bar")`,
right: `Some("Foo & Bar")`', src/main.rs:10:21
Expected behaviour: The entities are decoded. Actual behaviour: The source representation of the attribute contents are returned.
Workaround: Manually decode the string returned from get_attribute.