11 releases (6 breaking)

0.8.1 Jun 2, 2024
0.8.0 Sep 9, 2023
0.7.0 Jan 7, 2020
0.6.0 Oct 20, 2019
0.2.0 Dec 12, 2017

#1617 in Web programming

Download history 627/week @ 2024-09-11 557/week @ 2024-09-18 538/week @ 2024-09-25 428/week @ 2024-10-02 861/week @ 2024-10-09 551/week @ 2024-10-16 887/week @ 2024-10-23 793/week @ 2024-10-30 638/week @ 2024-11-06 628/week @ 2024-11-13 597/week @ 2024-11-20 719/week @ 2024-11-27 746/week @ 2024-12-04 638/week @ 2024-12-11 744/week @ 2024-12-18 164/week @ 2024-12-25

2,498 downloads per month
Used in localapp

MIT license

45KB
1K SLoC

Sanitize HTML

Crates.io Status Build codecov 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–9MB
~88K SLoC