pub fn escape_html(value: &str) -> String
Expand description
Escapes special HTML characters in a string.
This function replaces the following characters with their HTML entity equivalents:
&
becomes&
<
becomes<
>
becomes>
"
becomes"
'
becomes'
§Arguments
value
- The string to escape.
§Returns
A new string with special HTML characters escaped.
§Examples
use metadata_gen::utils::escape_html;
let input = "Hello, <world>!";
let expected = "Hello, <world>!";
assert_eq!(escape_html(input), expected);
§Security
This function is designed to prevent XSS (Cross-Site Scripting) attacks by escaping potentially dangerous characters. However, it should not be relied upon as the sole method of sanitizing user input for use in HTML contexts.