11 releases (6 breaking)

0.8.1 Jun 2, 2024
0.8.0 Sep 9, 2023
0.7.0 Jan 7, 2020
0.6.0 Oct 20, 2019
0.2.0 Dec 12, 2017

#2 in #predefined

Download history 437/week @ 2024-04-04 508/week @ 2024-04-11 477/week @ 2024-04-18 542/week @ 2024-04-25 349/week @ 2024-05-02 371/week @ 2024-05-09 455/week @ 2024-05-16 564/week @ 2024-05-23 479/week @ 2024-05-30 340/week @ 2024-06-06 206/week @ 2024-06-13 220/week @ 2024-06-20 157/week @ 2024-06-27 407/week @ 2024-07-04 386/week @ 2024-07-11 192/week @ 2024-07-18

1,216 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–9.5MB
~86K SLoC