Skip to main content

sanitize_html

Function sanitize_html 

Source
pub fn sanitize_html(src: &str) -> String
Expand description

Sanitize an HTML string for richtext storage / preview. Uses the same ammonia allow-list as the markdown renderer, PLUS the move-safe internal-link attributes <a linktype="page|media" id="N"> that the | richtext filter resolves to real URLs at render time. Ammonia’s default policy strips unknown <a> attributes, which would drop the linktype/id pair and turn move-safe links into broken ones the next time a page is moved — so they’re explicitly allow-listed here. Both are inert (no script/URL vector), so allowing them is XSS-safe. Used by the richtext on-save sanitizer (sanitized_extension_form) and the preview pane.