ammonia
HTML Sanitization
4.1.4
14M downloads/mo
#2554 most downloaded on crates.io
rust-ammonia/ammonia
What this package is like to depend on
Last release 1 months ago
22 Jul 2026
Release timing varies
gaps range from 3 weeks to 1.3 years
Nearly every release is documented
notes for 19 of 19 stable releases
26 versions withdrawn
withdrawn after publishing
11 years old
45 releases · first in 2015
9 releases in the last 12 months
see the full history below
Release timeline
45 releases · Sep 2015 to Jul 2026Releases
latest 45-
4.1.422 Jul 2026Release notes
Open source →- fix: SVG
animationandsetcan cause XSS, becauseattributeNameis not checked (reported by Younghun Ko, koyokr)
Release notes
Open source →- fix: SVG
animationandsetcan cause XSS, becauseattributeNameis not checked (reported by Younghun Ko, koyokr)
- fix: SVG
-
4.1.330 Jun 2026Release notes
Open source →- fix: unexpected namespace switches after cleanup on MathML annotation-xml can cause mXSS
Special thanks to Ivan Ivančić (ivan0912, YesWeHack) for finding this vulnerability!
Release notes
Open source →-
fix: unexpected namespace switches after cleanup on MathML
annotation-xmlcan cause mXSS (reported by Ivan Ivančić) -
chore: upgrade to html5ever 0.37.1
-
chore: always strip the contents of
selectedcontentelements, since the parser will always replace it with the actual contents anyway
-
4.1.222 Sep 2025Release notes
Open source →- fix: unexpected namespace switches after cleanup can cause mXSS (reported by [email protected])
Release notes
Open source →- fix: unexpected namespace switches after cleanup can cause mXSS (reported by [email protected])
-
4.1.108 Jul 2025 -
4.1.021 Apr 2025Release notes
Open source →- chore: bump MSRV to 1.80.0
- chore: switch to
std'sLazyLockinstead ofonce_cell'sLazy - feature: improve panic message when
clean_content_tagsconflicts with other options - feature: add support for sanitizing the
styleattribute
-
4.0.322 Jul 2026Release notes
Open source →- fix: SVG
animationandsetcan cause XSS, becauseattributeNameis not checked (reported by Younghun Ko, koyokr)
- fix: SVG
-
4.0.230 Jun 2026Release notes
Open source →- fix: unexpected namespace switches after cleanup on MathML annotation-xml can cause mXSS
Special thanks to Ivan Ivančić (ivan0912, YesWeHack) for finding this vulnerability!
-
4.0.122 Sep 2025Release notes
Open source →- fix: unexpected namespace switches after cleanup can cause mXSS (reported by [email protected], backport 4.1.2)
Release notes
Open source →- fix: unexpected namespace switches after cleanup can cause mXSS (backport 4.1.2)
-
4.0.025 Mar 2024Release notes
Open source →- Update html5ever to 0.27
- feature: change lifetimes on UrlRelative (breaking change)
- chore: use the
Displaytrait (andToString) instead of an inherentto_stringmethod (breaking change) - Security fixes are not backported to the 2.0 branch any more. Only the v3 and v4 branches are supported.
-
3.3.322 Jul 2026Release notes
Open source →- fix: SVG
animationandsetcan cause XSS, becauseattributeNameis not checked (reported by Younghun Ko, koyokr)
- fix: SVG
-
3.3.230 Jun 2026Release notes
Open source →- fix: unexpected namespace switches after cleanup on MathML
annotation-xmlcan cause mXSS
Special thanks to Ivan Ivančić (ivan0912, YesWeHack) for finding this vulnerability!
- fix: unexpected namespace switches after cleanup on MathML
-
3.3.122 Sep 2025Release notes
Open source →- fix: unexpected namespace switches after cleanup can cause mXSS (reported by [email protected], backport 4.1.2)
Release notes
Open source →- fix: unexpected namespace switches after cleanup can cause mXSS (backport 4.1.2, reported by [email protected])
-
3.3.029 Nov 2022Release notes
Open source →- chore: bump MSRV to 1.60.0
- docs: fix incorrect XSS example
- feature: add
UrlRelative::RewriteWithRoot
-
3.2.115 Aug 2022Release notes
Open source →- chore: bump MSRV to 1.51.0 https://github.com/serde-rs/serde/issues/2255
- chore: fix broken links in documentation
-
3.2.007 Apr 2022Release notes
Open source →- chore: bump MSRV to 1.49.0
- chore: update to html5ever 0.26
- chore: switch from lazy_static to once_cell
- feature: add
Builder::empty()constructor
-
3.1.416 Feb 2022Release notes
Open source →- chore: use
#[non_exhaustive]instead of hidden variant forUrlRelativepolicy - chore: remove unnecessary dependency on third-party
matches!macro
- chore: use
-
3.1.319 Jan 2022Release notes
Open source →- fix: incorrect FF/CR handling in
clean_text - fix: split class name attribute by all ASCII whitespace, not just SP 0x20
- docs: fix incorrect English in
is_htmldocumentation
- fix: incorrect FF/CR handling in
-
3.1.208 Jul 2021 withdrawn -
3.1.105 Mar 2021 withdrawn -
3.1.010 Mar 2020 withdrawnRelease notes
Open source →- feature: Whitelist generic attribute prefix
- chore: Update html5ever to 0.25
- feature: support adding attribute values to elements
-
3.0.025 Jul 2019 withdrawnRelease notes
Open source →- Add
clean_textfunction. - Updated to rust-url 2.0.
- Updated to the 2018 edition.
- Add
-
2.1.419 Jan 2022Release notes
Open source →- fix: split class name attribute by all ASCII whitespace, not just SP 0x20 (backported from 3.1.3)
-
2.1.308 Jul 2021Release notes
Open source →- fix: unexpected namespace switches can allow XSS via svg/mathml parsing (backported from 3.1.2)
-
2.1.228 Jun 2019 withdrawn -
2.1.108 May 2019 withdrawn -
2.1.027 Apr 2019 withdrawnRelease notes
Open source →- Bump minimum supported Rust version to 1.30.
- Fix a potential DoS attack from pathologically nested input.
-
2.0.028 Dec 2018 withdrawnRelease notes
Open source →- Add "script" and "style" to the default set of clean content tags
- Make all iterator-accepting APIs use
IntoIteratorandBorrow, so that you can pass slices directly to them.
-
1.2.018 Jul 2018 withdrawnRelease notes
Open source →- Recognize
action,formactionandpingas URL attributes for scheme and origin filtering - Add
Builder::url_filter_mapwhich allows URLs, both relative and absolute, to be pre-filtered
- Recognize
-
1.1.004 Mar 2018 withdrawnRelease notes
Open source →- Add
Builder::clean_content_tagswhich allows elements to be removed entirely instead of just having the tags removed
- Add
-
1.0.124 Dec 2017 withdrawn -
1.0.012 Nov 2017 withdrawnRelease notes
Open source →- Breaking change: The
Ammoniastruct is now calledBuilderand uses that pattern for better forward compatibility - Breaking change: The
Builder::clean()method now returns aDocumentstruct instead of aString. You can use theDocument::to_stringmethod to obtain aString. - Breaking change:
keep_cleaned_elementshas changed from being an off-by-default option to the only supported behavior - Breaking change: Using a tag with
allowed_classesmeans that the class attribute is banned fromtag_attributes(it used to be required) - Breaking change: The default set of allowed elements and attributes was expanded
- Added support for reading the input from a stream
- Added
UrlRelative::Custom, allowing you to write your own relative URL resolver - Changed
UrlRelative::RewriteWithBasetake a custom URL. This made theurlcrate a public dependency. - Added
id_prefix, which can be used to avoid elementidcollisions with the rest of the page - Added property getters to
Builder, to see what everything is currently set to - Added property modifiers, to change the existing whitelist (instead of completely replacing it)
- Breaking change: The
-
1.0.0-rc326 Oct 2017 pre-release withdrawnNothing published for this version
-
1.0.0-rc224 Oct 2017 pre-release withdrawnNothing published for this version
-
1.0.0-rc126 Sep 2017 pre-release withdrawnNothing published for this version
-
0.7.029 Aug 2017 withdrawnRelease notes
Open source →- Add
allowed_classes, allowing the user to set only specific items that can go in the class attribute
- Add
-
0.6.129 Aug 2017 withdrawn -
0.6.021 Aug 2017 withdrawnRelease notes
Open source →- Resolve relative URLs with a given base (off by default, you need to specify that base URL)
- Add
rel="noreferrer noopener"to links, as a security measure - Avoid closing void tags, such as turning
<br>into<br></br> - Bump the html5ever version
- Switch to using docs.rs to host docs
-
0.5.016 Jun 2017 withdrawn -
0.4.009 Jun 2017 withdrawn -
0.3.023 Mar 2017 withdrawn -
0.2.014 Mar 2017 withdrawnRelease notes
Open source →- Removed the strip option. Not a security problem, but it was wrong and looked stupid. I'm not going to reintroduce this until html5ever allows me to preserve the original text enough to have non-stripped tags come out exactly like they go in.
- Treat the data attribute of object as a URL. In non-default configurations, this could have been a leak.
- Update to the newest html5ever.
-
0.1.316 Nov 2016 withdrawnNothing published for this version
-
0.1.227 Jun 2016 withdrawnNothing published for this version
-
0.1.129 Dec 2015 withdrawnNothing published for this version
-
0.1.004 Sep 2015 withdrawnNothing published for this version