sanitizeHtml
Textarea
stable
Walk a DOMParser-parsed tree and remove disallowed tags, attributes, and event handlers. Returns the cleaned HTML string. SSR-safe: returns the raw input when DOMParser is unavailable.
API
Signature
Full TypeScript signature sourced from the util file.
Used internally by OrigamTextareaField in mode="rich". The allowlist is defined by ALLOWED_TAGS, ALLOWED_ATTRIBUTES, BLOCKED_TAGS, and ALLOWED_URL_SCHEMES constants in the DS.
API
Parameters
Input parameters accepted by this util.
- inputrequiredstring
- The raw HTML string to sanitise. Null or empty string returns an empty string immediately.
API
Return value
The value returned by this util.
- The sanitised HTML string with all blocked tags, unknown attributes, and on* handlers removed.
Usage
Examples
Ready-to-paste usage snippets.
Strip script tags and event handlers