Package com.google.gwt.safehtml.shared
Class SimpleHtmlSanitizer
- java.lang.Object
-
- com.google.gwt.safehtml.shared.SimpleHtmlSanitizer
-
- All Implemented Interfaces:
HtmlSanitizer
public final class SimpleHtmlSanitizer extends java.lang.Object implements HtmlSanitizer
A simple and relatively inexpensive HTML sanitizer.This sanitizer accepts the subset of HTML consisting of the following attribute-free tags:
<b>,<em>,<i><h1>,<h2>,<h3>,<h4>,<h5>,<h6><ul>,<ol>,<li><br>,<hr>,<strong>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SimpleHtmlSanitizergetInstance()Return a singleton SimpleHtmlSanitizer instance.SafeHtmlsanitize(java.lang.String html)Sanitizes a string intoSafeHtml.static SafeHtmlsanitizeHtml(java.lang.String html)HTML-sanitizes a string.
-
-
-
Method Detail
-
getInstance
public static SimpleHtmlSanitizer getInstance()
Return a singleton SimpleHtmlSanitizer instance.- Returns:
- the instance
-
sanitizeHtml
public static SafeHtml sanitizeHtml(java.lang.String html)
HTML-sanitizes a string.The input string is processed as described above. The result of sanitizing the string is guaranteed to be safe to use (with respect to XSS vulnerabilities) in HTML contexts, and is returned as an instance of the
SafeHtmltype.- Parameters:
html- the input String- Returns:
- a sanitized SafeHtml instance
-
sanitize
public SafeHtml sanitize(java.lang.String html)
Description copied from interface:HtmlSanitizerSanitizes a string intoSafeHtml.- Specified by:
sanitizein interfaceHtmlSanitizer- Parameters:
html- String containing untrusted HTML.- Returns:
- Contents of
html, sanitized according to the policy implemented by this sanitizer.
-
-