#html #sanitize

sanitize_html

Rule-based HTML Sanitization library

9 releases (5 breaking)

0.7.0 Jan 7, 2020
0.6.0 Oct 20, 2019
0.5.1 Aug 5, 2019
0.5.0 Jul 2, 2019
0.2.0 Dec 12, 2017

#223 in #html

Download history 35/week @ 2022-03-10 65/week @ 2022-03-17 20/week @ 2022-03-24 15/week @ 2022-03-31 26/week @ 2022-04-07 15/week @ 2022-04-14 27/week @ 2022-04-21 89/week @ 2022-04-28 74/week @ 2022-05-05 260/week @ 2022-05-12 116/week @ 2022-05-19 147/week @ 2022-05-26 127/week @ 2022-06-02 90/week @ 2022-06-09 55/week @ 2022-06-16 166/week @ 2022-06-23

455 downloads per month
Used in localapp

MIT license

45KB
1K SLoC

Sanitize HTML

Crates.io Status Build Status 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
~181K SLoC