Skip to main content

escape_attribute

Function escape_attribute 

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

Escapes a value for use inside a double-quoted HTML attribute.

Deliberately narrower than escape_text: < and > are left alone, because they cannot terminate a quoted attribute value. Winged-Swift’s HTMLEscape.escapeAttribute does the same, and marketing-pretty.html contains attribute values that prove it.

§Examples

use winged_rust::core::escape::escape_attribute;
assert_eq!(escape_attribute(r#"a "b" & <c>"#), "a &quot;b&quot; &amp; <c>");