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

Add method for removing tag contents #89

Closed
mattico opened this issue Feb 27, 2018 · 1 comment
Closed

Add method for removing tag contents #89

mattico opened this issue Feb 27, 2018 · 1 comment

Comments

@mattico
Copy link
Contributor

mattico commented Feb 27, 2018

I'd like to be able to take an HTML snippet and remove everything that isn't plain text. This includes things like the contents of <script> and <style> tags. Essentially:

assert_eq!(ammonia::clean(r"
<script type='text/javascript'>XSS</script>
Some <em>text</em> here!
<style>a { font-size: 14px; }</style>
"), "Some text here!");

I'm willing to make a PR for this, but I don't know how the API should look. Builder::remove_content_tags()?

@notriddle
Copy link
Member

Sounds good to me.

bors bot added a commit that referenced this issue Mar 2, 2018
90: Add clean_content_tags() r=notriddle a=mattico

Here's a basic implementation. I'm not completely sure how it should interact with the whitelist:

1. If a tag is in the blacklist that takes precedence, and the whitelist is ignored for that tag. (currently implemented)
2. If a tag is in both blacklist and whitelist then panic. (annoying to use with default options but explicit)
3. When a tag is added to the blacklist, it's automatically removed from the whitelist. (adds complexity and doesn't work well with `rm_clean_content_tags`, but is consistent)

Also I think defaulting to `clean_content_tags(["script", "style"])` is a good idea, but I know defaults are hard to change.

Closes #89
@bors bors bot closed this as completed in #90 Mar 2, 2018
notriddle added a commit that referenced this issue Mar 3, 2018
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

2 participants