Struct ammonia::Ammonia
[−]
[src]
pub struct Ammonia<'a> { pub tags: HashSet<&'a str>, pub tag_attributes: HashMap<&'a str, HashSet<&'a str>>, pub generic_attributes: HashSet<&'a str>, pub url_schemes: HashSet<&'a str>, pub url_relative: bool, pub strip_comments: bool, pub keep_cleaned_elements: bool, }
Settings for HTML cleaning.
Fields
Tags that are allowed. Note that this only whitelists the tag; it will still be stripped if it has unlisted attributes.
tag_attributes: HashMap<&'a str, HashSet<&'a str>>
Attributes that are allowed on certain tags. If the tag is not itself whitelisted, adding entries to this map do nothing. It is structured as a map from tag name to set of attribute name.
generic_attributes: HashSet<&'a str>
Attributes that are allowed on any tag.
url_schemes: HashSet<&'a str>
Permitted URL schemes on href and src attributes.
url_relative: bool
Permit relative URLs on href and src attributes.
strip_comments: bool
True: strip HTML comments. False: leave HTML comments in.
keep_cleaned_elements: bool
True: remove disallowed attributes, but not the elements containing them. False: remove elements with disallowed attributes.
Methods
impl<'a> Ammonia<'a>
[src]
fn clean(&self, src: &'a str) -> String
Given a fragment of HTML, Ammonia will parse it according to the HTML5 parsing algorithm and sanitize any disallowed tags or attributes. This algorithm also takes care of things like unclosed and (some) misnested tags.