htmlsanitizer-0.1.0 has been yanked.
htmlsanitizer
A fast, allowlist-based HTML sanitizer for Rust.
Ported from sym01/htmlsanitizer (Go).
Features
- O(n) streaming FSM parser — no DOM tree allocation
- Allowlist-based: only explicitly permitted tags and attributes pass through
- URL attribute sanitization (rejects
javascript:,data:, etc.) - Customizable allow list and URL sanitizer
- Optional WASM/npm support via the
wasmfeature
Usage
use ;
// Quick one-shot sanitization with the default allow list
let safe = sanitize_string;
assert_eq!;
// Custom sanitizer with a modified allow list
let mut s = new;
s.allow_list.remove_tag;
let safe = s.sanitize_string;
assert_eq!;
License
MIT