Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Entities are not Decoded in Attributes. #131

Open
kevincox opened this issue May 23, 2022 · 0 comments
Open

HTML Entities are not Decoded in Attributes. #131

kevincox opened this issue May 23, 2022 · 0 comments

Comments

@kevincox
Copy link

kevincox commented May 23, 2022

#[test]
fn test() {
	lol_html::rewrite_str(
		r#"
		<img alt="Foo &amp; 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 &amp; 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant