DOMPurify strips XSS vectors, Shannon entropy gates catch leaked credentials, and script-context detection flags data-exfiltration calls — all before the file is stored.
1
DOMPurify sanitize
Strips script, link, meta, iframe, form + all event handler attrs (onerror, onclick, etc.)
→ CLEAN
2
Link hardening
All <a> and <area> get rel="nofollow noopener noreferrer" + target="_blank"
→ SAFE
3
Credential scan
Shannon entropy ≥ 3.5 — AWS keys, GitHub PATs, Stripe secrets → [REDACTED]
→ REDACT
4
Prompt injection scan
"Ignore previous instructions" flagged ONLY inside HTML comments — visible text is allowed
→ STRIP
5
Exfil detection
fetch() and sendBeacon in <script> blocks flagged unless calling explainers.fyi or fonts.googleapis.com
→ FLAG