public final class Sanitizers extends Object
These policies can be used to sanitize content.
Sanitizers.FORMATTING.sanitize( "<b>Hello, World!</b>"
)
and can be chained
PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);
System.out.println(sanitizer.sanitize( "<p>Hello, <b>World!</b>"
));
For more fine-grained control over sanitization, use
HtmlPolicyBuilder
.
Modifier and Type | Field and Description |
---|---|
static PolicyFactory |
BLOCKS
Allows common block elements including
<p> ,
<h1> , etc. |
static PolicyFactory |
FORMATTING
Allows common formatting elements including
<b> , <i> , etc. |
static PolicyFactory |
IMAGES
Allows
<img> elements from HTTP, HTTPS, and relative sources. |
static PolicyFactory |
LINKS
Allows HTTP, HTTPS, MAILTO, and relative links.
|
static PolicyFactory |
STYLES
Allows certain safe CSS properties in
style="..." attributes. |
static PolicyFactory |
TABLES
Allows common table elements.
|
public static final PolicyFactory FORMATTING
<b>
, <i>
, etc.public static final PolicyFactory BLOCKS
<p>
,
<h1>
, etc.public static final PolicyFactory STYLES
style="..."
attributes.public static final PolicyFactory LINKS
public static final PolicyFactory TABLES
public static final PolicyFactory IMAGES
<img>
elements from HTTP, HTTPS, and relative sources.Copyright © 2018 OWASP. All rights reserved.