12 releases (7 breaking)
new 0.9.0 | May 2, 2025 |
---|---|
0.8.1 | Jun 2, 2024 |
0.8.0 | Sep 9, 2023 |
0.7.0 | Jan 7, 2020 |
0.2.0 | Dec 12, 2017 |
#1 in #sanitize
3,160 downloads per month
Used in 2 crates
45KB
1K
SLoC
HTML Sanitization library
Examples
use sanitize_html::sanitize_str;
use sanitize_html::rules::predefined::DEFAULT;
let input = "<b>Lo<!-- comment -->rem</b> <a href=\"pants\" title=\"foo\">ipsum</a> <a href=\"http://foo.com/\"><strong>dolor</strong></a> sit<br/>amet <script>alert(\"hello world\");</script>";
let sanitized_default: String = sanitize_str(&DEFAULT, input).unwrap();
assert_eq!(&sanitized_default, "Lorem ipsum dolor sit amet ");
Sanitize HTML
This is a library for sanitization of HTML fragments.
Dependencies
~3.5–9MB
~85K SLoC