tl icon indicating copy to clipboard operation
tl copied to clipboard

cannot handle single quote (`'`) string attributes with double quote (`"`) in content

Open Akronae opened this issue 1 year ago • 0 comments

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.

Akronae avatar Mar 03 '24 16:03 Akronae