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

#3 in #predefined

Download history 99/week @ 2023-12-14 67/week @ 2023-12-21 62/week @ 2023-12-28 89/week @ 2024-01-04 126/week @ 2024-01-11 165/week @ 2024-01-18 164/week @ 2024-01-25 228/week @ 2024-02-01 285/week @ 2024-02-08 370/week @ 2024-02-15 313/week @ 2024-02-22 339/week @ 2024-02-29 285/week @ 2024-03-07 151/week @ 2024-03-14 266/week @ 2024-03-21 380/week @ 2024-03-28

1,132 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–11MB
~89K SLoC