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', 'head' and 'body' tags are stripped out even if these are included in the whitelisted tags #183

Open
Muntaner opened this issue Jul 5, 2023 · 3 comments · May be fixed by #202
Open

Comments

@Muntaner
Copy link

Muntaner commented Jul 5, 2023

Minimal example:

    use maplit::hashset;

    let html = "<html><head>head content</head><body><div>test</div></body></html>";

    let tags = hashset!["html", "head", "body"];

    let mut b = ammonia::Builder::default();

    b.add_tags(tags);

    let clean_html = b.clean(html).to_string();
    println!("{}", clean_html);

Output: head content<div>test</div>
Expectation: <html><head>head content</head><body><div>test</div></body></html>

Am I overlooking some setting?

@medihack
Copy link

Same thing for some other tags, like strong. Any help?

@notriddle
Copy link
Member

html, head, and body are more-or-less expected. The HTML is parsed as-if it was a div's innerHTML.

strong shouldn't do that. Can you open a separate issue with a minimized code example?

@Muntaner
Copy link
Author

Muntaner commented Jul 30, 2023

html, head, and body are more-or-less expected. The HTML is parsed as-if it was a div's innerHTML.

Does this mean that it is working as designed (I doubt that, due to the "more-or-less") or is there any plan to support such tags?

Imho it could be very useful. Right now passing a full fledged HTML doc to the library for sanitization is basically unsupported, since it would "break" the original doc.

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

Successfully merging a pull request may close this issue.

3 participants