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

Signature TypeScript complète, extraite du fichier util.

typescript

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

Paramètres

Paramètres d'entrée acceptés par cet util.

input
requis
string
The raw HTML string to sanitise. Null or empty string returns an empty string immediately.

API

Valeur de retour

La valeur retournée par cet util.

The sanitised HTML string with all blocked tags, unknown attributes, and on* handlers removed.

Usage

Exemples

Extraits de code prêts à coller.

Strip script tags and event handlers

typescript