sanitize_html

Function sanitize_html 

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

Sanitize HTML to prevent XSS attacks

This function escapes HTML special characters to prevent script injection. Use this for any user-provided content that will be displayed in HTML contexts.

ยงExample

use mockforge_core::validation::sanitize_html;

let malicious = "<script>alert('xss')</script>";
let safe = sanitize_html(malicious);
assert_eq!(safe, "&lt;script&gt;alert(&#39;xss&#39;)&lt;&#x2F;script&gt;");