pub fn escape(input: &str) -> StringExpand description
Escapes special HTML characters in a string to prevent XSS attacks or unintended HTML rendering. This function converts:
&to&<to<>to>"to"'to'
§Arguments
input- A string slice that may contain special HTML characters.
§Returns
A String with all special HTML characters replaced by their respective
HTML entities.
§Examples
let raw_html = "5 < 7 & 5 > 3";
let safe_html = fhtml::escape(raw_html);
assert_eq!(safe_html, "5 < 7 & 5 > 3");