HTML sanitizer aligned with current browsers

Last modified by Michael Hamann on 2026/11/17 15:46

The HTML sanitizer that cleans user-generated HTML follows the latest version of DOMPurify, the library it is adapted from, more closely:

  • More safe elements and attributes are allowed, such as search, slot, popover, inert, the SVG filter feDropShadow and the MathML element mprescripts. The sms: and matrix: protocols are also part of the default xml.htmlElementSanitizer.allowedUriRegexp.
  • SVG elements with camel case names like linearGradient or clipPath, and the MathML attribute columnalign, are no longer removed.
  • The for attribute is only allowed on label and output, and HTML content inside the SVG elements desc and title is removed, as browsers would otherwise treat it differently from the sanitizer.

Get Connected