#html #sanitize

sanitize_html

Rule-based HTML Sanitization library

7 unstable releases (3 breaking)

✓ Uses Rust 2018 edition

new 0.5.1 Aug 5, 2019
0.5.0 Jul 2, 2019
0.4.0 May 3, 2019
0.3.2 May 2, 2019
0.2.0 Dec 12, 2017

#42 in Template engine

Download history 4/week @ 2019-04-22 25/week @ 2019-04-29 12/week @ 2019-05-06 8/week @ 2019-05-13 20/week @ 2019-05-20 20/week @ 2019-05-27 5/week @ 2019-06-03 10/week @ 2019-06-10 9/week @ 2019-06-17 23/week @ 2019-06-24 55/week @ 2019-07-01 29/week @ 2019-07-08 3/week @ 2019-07-15 1/week @ 2019-07-22 7/week @ 2019-07-29

66 downloads per month

MIT license

46KB
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 alert(\"hello world\");");

Dependencies

~3MB
~75K SLoC