10 releases (6 breaking)

0.8.0 Sep 9, 2023
0.7.0 Jan 7, 2020
0.6.0 Oct 20, 2019
0.5.0 Jul 2, 2019
0.2.0 Dec 12, 2017

#2 in #predefined

Download history 196/week @ 2024-01-30 255/week @ 2024-02-06 359/week @ 2024-02-13 293/week @ 2024-02-20 378/week @ 2024-02-27 299/week @ 2024-03-05 228/week @ 2024-03-12 160/week @ 2024-03-19 312/week @ 2024-03-26 457/week @ 2024-04-02 509/week @ 2024-04-09 539/week @ 2024-04-16 494/week @ 2024-04-23 332/week @ 2024-04-30 391/week @ 2024-05-07 429/week @ 2024-05-14

1,766 downloads per month
Used in localapp

MIT license

45KB
1K SLoC

Sanitize HTML

Crates.io Status Build codecov dependency status

This is a library for sanitization of HTML fragments.


lib.rs:

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 ");

Dependencies

~3.5–10MB
~89K SLoC