Sanitizer

open class Sanitizer(configuration: SanitizerConfig = definedExternally)(source)

The Sanitizer interface of the HTML Sanitizer API defines a configuration object that specifies what elements, attributes and comments are allowed or should be removed when inserting strings of HTML into an Element or ShadowRoot, or when parsing an HTML string into a Document.

Constructors

Link copied to clipboard
constructor(configuration: SanitizerConfig = definedExternally)
constructor(configuration: SanitizerPresets)

Functions

Link copied to clipboard

The allowAttribute() method of the Sanitizer interface sets an attribute to be allowed on all elements when the sanitizer is used.

Link copied to clipboard

The allowElement() method of the Sanitizer interface sets that the specified element is allowed in the output when the sanitizer is used.

Link copied to clipboard

The get() method of the Sanitizer interface returns a SanitizerConfig dictionary instance that represents the current Sanitizer configuration.

Link copied to clipboard

The removeAttribute() method of the Sanitizer interface sets an attribute to be removed from all elements when the sanitizer is used.

Link copied to clipboard

The removeElement() method of the Sanitizer interface sets the specified element be removed from the output when the sanitizer is used.

Link copied to clipboard

The removeUnsafe() method of the Sanitizer interface configures the sanitizer configuration so that it will remove all elements, attributes, and event handler content attributes that are considered XSS-unsafe by the browser.

Link copied to clipboard

The replaceElementWithChildren() method of the Sanitizer interface sets an element to be replaced by its child HTML elements when the sanitizer is used. This is primarily used for stripping styles from text.

Link copied to clipboard

The setComments() method of the Sanitizer interface sets whether comments will be allowed or removed by the sanitizer.

Link copied to clipboard

The setDataAttributes() method of the Sanitizer interface sets whether all data-* attributes will be allowed by the sanitizer, or if they must be individually specified.