sanitize_html

Function sanitize_html 

Source
pub fn sanitize_html(input: &str) -> String
Expand description

Sanitize HTML content, removing dangerous tags and attributes

This function uses ammonia to clean HTML content, allowing only safe tags and attributes. It’s designed to match feedparser’s sanitization behavior.

§Arguments

  • input - HTML string to sanitize

§Returns

Sanitized HTML string with dangerous content removed

§Examples

use feedparser_rs::util::sanitize::sanitize_html;

let unsafe_html = r#"<p>Hello</p><script>alert('XSS')</script>"#;
let safe_html = sanitize_html(unsafe_html);
assert_eq!(safe_html, "<p>Hello</p>");