Crate sanitize_html

source ·
Expand description

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\");");

Modules

Error types, which can be emited by sanitization procedure.
Structures to define sanitization rules.

Functions

Sanitize HTML bytes
Sanitize HTML string