tl
tl copied to clipboard
cannot handle single quote (`'`) string attributes with double quote (`"`) in content
This example will fail:
fn main() -> () {
let str = r#"<!DOCTYPE html>
<html>
<body>
<meta data-mw='{"autoGenerated":true}' />
hey
</body>
</html>
"#;
let dom = tl::parse(str, Default::default()).unwrap();
let parser = dom.parser();
let inner_html = dom
.children()
.get(1)
.unwrap()
.get(parser)
.unwrap()
.inner_html(parser)
.to_string();
dbg!(inner_html);
}
<meta data-mw='{"autoGenerated":true}' />
will be changed to
<meta data-mw="{"autoGenerated":true}">
due to incorrect single quote to double quote substitution, thus the tag is left open and is messing with the entire DOM.
Took me quite some time to realize what was happening.