#html #sanitize

sanitize_html

Rule-based HTML Sanitization library

5 unstable releases

✓ Uses Rust 2018 edition

0.4.0 May 3, 2019
0.3.2 May 2, 2019
0.3.1 Dec 23, 2018
0.3.0 May 8, 2018
0.2.0 Dec 12, 2017

#35 in Template engine

20 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
~56K SLoC