Replace Transformer with Sanitizer
Tried to keep them separate but it was starting to get too messy. Users can just pass in custom transformers in the second constructor argument. Plus, this more closely matches the ruby sanitize API. Changed config to be a struct. So far, have only made a `DEFAULT_CONFIG`. Need to make all of the others as well. Started working on a `remove_contents_when_unwrapped` option to the config that will indicate whether to remove contents of elements that are unwrapped.
This commit is contained in:
25
src/config/default.rs
Normal file
25
src/config/default.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use crate::sanitizer::SanitizerConfig;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref DEFAULT_CONFIG: SanitizerConfig = SanitizerConfig {
|
||||
allow_comments: false,
|
||||
allowed_elements: HashSet::new(),
|
||||
allowed_attributes: HashSet::new(),
|
||||
allowed_attributes_per_element: HashMap::new(),
|
||||
add_attributes: HashMap::new(),
|
||||
add_attributes_per_element: HashMap::new(),
|
||||
allowed_protocols: HashMap::new(),
|
||||
allowed_css_at_rules: HashSet::new(),
|
||||
allowed_css_properties: HashSet::new(),
|
||||
remove_contents_when_unwrapped: hashset! {
|
||||
local_name!("iframe"),
|
||||
local_name!("noembed"),
|
||||
local_name!("noframes"),
|
||||
local_name!("noscript"),
|
||||
local_name!("script"),
|
||||
local_name!("style"),
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user