public final class HtmlSanitizer extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
HtmlSanitizer.Policy
Receives events based on the HTML stream, and applies a policy to decide
what HTML constructs to allow.
|
Constructor and Description |
---|
HtmlSanitizer() |
Modifier and Type | Method and Description |
---|---|
static void |
sanitize(String html,
HtmlSanitizer.Policy policy)
Sanitizes the given HTML by applying the given policy to it.
|
public static void sanitize(@Nullable String html, HtmlSanitizer.Policy policy)
This method is not in the TCB.
This method has no return value since policies are assumed to render things
they accept and do nothing on things they reject.
Use HtmlStreamRenderer
to render content to an output buffer.
html
- A snippet of HTML to sanitize. null
is treated as the
empty string and will not result in a NullPointerException
.policy
- The Policy that will receive events based on the tokens in
HTML. Typically, this policy ends up routing the events to an
HtmlStreamRenderer
after filtering.
HtmlPolicyBuilder
provides an easy way to create policies.Copyright © 2015. All rights reserved.