Sanitize KaTeX-generated HTML output. Meant for KaTeX's own output only
(rendered with trust: false): it is a denylist, not a general sanitizer —
use sanitizeHTML for other HTML.
Lighter than sanitizeHTML — preserves SVG elements and inline styles
required for correct math rendering while removing injection vectors:
<script>, and elements KaTeX never emits that can run or load
content or change how the page parses (iframe, object, embed,
noscript, style, meta, base, form, SVG animate / set …)
on* event-handler attributes, srcdoc, and SVG animation values
(values / to / from / by)
javascript:/vbscript:/data: URLs in href/src/xlink:href/action/formaction
Works on a parsed tree, not regexes, so odd spellings (</script >,
<ScRiPt>, entities in URLs) can't slip through. Entities and markup are
otherwise written back as they were.
Sanitize KaTeX-generated HTML output. Meant for KaTeX's own output only (rendered with
trust: false): it is a denylist, not a general sanitizer — use sanitizeHTML for other HTML.Lighter than sanitizeHTML — preserves SVG elements and inline styles required for correct math rendering while removing injection vectors:
<script>, and elements KaTeX never emits that can run or load content or change how the page parses (iframe,object,embed,noscript,style,meta,base,form, SVGanimate/set…)srcdoc, and SVG animation values (values/to/from/by)Works on a parsed tree, not regexes, so odd spellings (
</script >,<ScRiPt>, entities in URLs) can't slip through. Entities and markup are otherwise written back as they were.