Skip to main content

encode_safe_to_vec

Function encode_safe_to_vec 

Source
pub fn encode_safe_to_vec<S: AsRef<str>>(text: S, output: &mut Vec<u8>) -> &[u8] 
Expand description

Encode &, <, >, ", ', and / as HTML entities, write the result to a mutable Vec<u8> reference, and return the encoded data slice.

This function is not a context-independent sanitizer. Use a context-specific encoder for text, attributes, scripts, and styles.

The following characters are escaped:

  • & => &amp;
  • < => &lt;
  • > => &gt;
  • " => &quot;
  • ' => &#x27;
  • / => &#x2F;