HTML Sanitizer

DOM-based HTML sanitization for safe insertion.

Access:

app.getService('htmlSanitizer')

App code:

const htmlSanitizer = app.getService('htmlSanitizer');

Plugin:

const htmlSanitizer = this.app.getService('htmlSanitizer');

sanitize#

Parses HTML into a template, removes tags listed in tags.denied, and sanitizes src/href/srcset URLs, inline styles, event attributes, xlink:href, and dangerous STYLE content.

Parameters:

  • html (string) — HTML string
  • options (object) — reserved for future use; currently not read by this method

Returns: string

htmlSanitizer.sanitize('<p onclick="alert(1)">Hi</p>');