@locker/html-sanitizer

Locker Next HTML and SVG sanitize utility package

Usage no npm install needed!

<script type="module">
  import lockerHtmlSanitizer from 'https://cdn.skypack.dev/@locker/html-sanitizer';
</script>

README

Description

The html-sanitize package provides a set of utilities meant to facilitate the sanitization of HTML and SVG strings and elements. It is built around DOMPurify.

Features

  • caching mechanism to store DOMPurify instances based on configuration objects. This avoids reparsing the configuration object.
  • utility functions meant to facilitate working with predefined configuration objects required by Locker in various scenarios, i.e sanitization of SVG strings, sanitization of Blob HTML content strings, sanitization of strings that are to be usd with innerHTML, outerHTML etc.
  • hook for sanitizing SVG network resources (even if they are nested).