Sanitizer Class

https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#sanitizer

public sealed class Sanitizer

Constructors

NameDescription
Sanitizer(SanitizerConfigOrSanitizerPresets?)https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-sanitizer-sanitizer

Sanitizer(SanitizerConfigOrSanitizerPresets?)

Sanitizer.cs

https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-sanitizer-sanitizer

public Sanitizer(SanitizerConfigOrSanitizerPresets? configuration = null)

Parameters

configuration SanitizerConfigOrSanitizerPresets?
The configuration, or null for the built-in safe default configuration ("default").

See also

Methods

NameDescription
AllowAttribute(SanitizerAttribute)Adds an attribute to the allow list of the configuration; returns whether the configuration changed.
AllowElement(SanitizerElementWithAttributes)Adds an element to the allow list of the configuration; returns whether the configuration changed.
AllowProcessingInstruction(SanitizerPI)Adds a processing instruction to the allow list of the configuration; returns whether the configuration changed.
Get()https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-sanitizer-get
RemoveAttribute(SanitizerAttribute)Adds an attribute to the remove list of the configuration; returns whether the configuration changed.
RemoveElement(SanitizerElement)Adds an element to the remove list of the configuration; returns whether the configuration changed.
RemoveProcessingInstruction(SanitizerPI)Adds a processing instruction to the remove list of the configuration; returns whether the configuration changed.
RemoveUnsafe()https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-sanitizer-removeunsafe
ReplaceElementWithChildren(SanitizerElement)Adds an element to the list of elements replaced with their children; returns whether the configuration changed.
SetComments(bool)Sets whether comments are allowed; returns whether the configuration changed.
SetDataAttributes(bool)Sets whether custom data-* attributes are allowed; returns whether the configuration changed.
SetJavaScriptUrls(bool)Sets whether javascript: URLs are allowed; returns whether the configuration changed.

AllowAttribute(SanitizerAttribute)

Sanitizer.cs

Adds an attribute to the allow list of the configuration; returns whether the configuration changed.

public bool AllowAttribute(SanitizerAttribute attribute)

AllowElement(SanitizerElementWithAttributes)

Sanitizer.cs

Adds an element to the allow list of the configuration; returns whether the configuration changed.

public bool AllowElement(SanitizerElementWithAttributes element)

AllowProcessingInstruction(SanitizerPI)

Sanitizer.cs

Adds a processing instruction to the allow list of the configuration; returns whether the configuration changed.

public bool AllowProcessingInstruction(SanitizerPI pi)

https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-sanitizer-get

public SanitizerConfig Get()

RemoveAttribute(SanitizerAttribute)

Sanitizer.cs

Adds an attribute to the remove list of the configuration; returns whether the configuration changed.

public bool RemoveAttribute(SanitizerAttribute attribute)

RemoveElement(SanitizerElement)

Sanitizer.cs

Adds an element to the remove list of the configuration; returns whether the configuration changed.

public bool RemoveElement(SanitizerElement element)

RemoveProcessingInstruction(SanitizerPI)

Sanitizer.cs

Adds a processing instruction to the remove list of the configuration; returns whether the configuration changed.

public bool RemoveProcessingInstruction(SanitizerPI pi)

RemoveUnsafe()

Sanitizer.cs

https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-sanitizer-removeunsafe

public bool RemoveUnsafe()

ReplaceElementWithChildren(SanitizerElement)

Sanitizer.cs

Adds an element to the list of elements replaced with their children; returns whether the configuration changed.

public bool ReplaceElementWithChildren(SanitizerElement element)

SetComments(bool)

Sanitizer.cs

Sets whether comments are allowed; returns whether the configuration changed.

public bool SetComments(bool allow)

SetDataAttributes(bool)

Sanitizer.cs

Sets whether custom data-* attributes are allowed; returns whether the configuration changed.

public bool SetDataAttributes(bool allow)

SetJavaScriptUrls(bool)

Sanitizer.cs

Sets whether javascript: URLs are allowed; returns whether the configuration changed.

public bool SetJavaScriptUrls(bool allow)