///|
test {
let safe = @dom_sanitizer.sanitize(
"<p onclick=\"alert(1)\">hi<script>alert(1)</script></p>",
)
inspect(safe, content="<p>hi</p>")
}///|
test {
let config = { ..@dom_sanitizer.Config::default(), safe_for_templates: true }
let safe = @dom_sanitizer.sanitize("<p>{{ user }}</p>", config~)
inspect(safe, content="<p> </p>")
}pub(all) struct Config {
allowed_tags : Array[String]?
allowed_attr : Array[String]?
allowed_namespaces : Array[String]?
add_tags : Array[String]?
add_tag_check : (String) -> Bool?
add_attr : Array[String]?
add_attr_check : (String, String) -> Bool?
add_data_uri_tags : Array[String]?
add_uri_safe_attr : Array[String]?
allow_aria_attr : Bool
allow_data_attr : Bool
allow_unknown_protocols : Bool
allow_self_close_in_attr : Bool
forbid_tags : Array[String]?
forbid_attr : Array[String]?
forbid_contents : Array[String]?
add_forbid_contents : Array[String]?
force_body : Bool
keep_content : Bool
namespace_uri : String
parser_media_type : String
safe_for_templates : Bool
safe_for_xml : Bool
sanitize_dom : Bool
sanitize_named_props : Bool
whole_document : Bool
use_profiles : UseProfilesConfig?
custom_element_handling : CustomElementHandling?
allowed_uri_check : (String) -> Bool?
html_integration_points : Array[String]?
mathml_text_integration_points : Array[String]?
}pub(all) struct CustomElementHandling {
tag_name_check : (String) -> Bool?
attribute_name_check : (String, String) -> Bool?
allow_customized_built_in_elements : Bool
}pub(all) struct UseProfilesConfig {
html : Bool
svg : Bool
svg_filters : Bool
math_ml : Bool
}let namespace_mathml : String