Skip to content

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

@Akronae

Description

@Akronae

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions