html-purifier

Crates.iohtml-purifier
lib.rshtml-purifier
version0.3.0
sourcesrc
created_at2020-02-24 21:00:33.055111
updated_at2024-01-31 17:15:23.601313
descriptionHTML Purifier
homepage
repositoryhttps://github.com/mehmetcansahin/html-purifier
max_upload_size
id212102
size11,057
mehmetcan (mehmetcansahin)

documentation

https://docs.rs/html-purifier

README

HTML Purifier

GHA Build Status MIT licensed crates.io Released API docs

HTML Purifier is a standard HTML filter library.

HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications. HTML Purifier

Example

use html_purifier::{purifier, Settings};

let settings = Settings {
    ..Settings::default()
};
let input = r#"<a href="/test" style="color: black;"><img src="/logo.png" onerror="javascript:;"/>Rust</a>"#;
let output = purifier(input, settings);

Input HTML

<a href="/test" style="color: black;"
  ><img src="/logo.png" onerror="javascript:;" />Rust</a
>

Output HTML

<a href="/test"><img src="/logo.png" />Rust</a>
Commit count: 19

cargo fmt