Package com.google.gwt.safehtml.shared
Class SimpleHtmlSanitizer
java.lang.Object
com.google.gwt.safehtml.shared.SimpleHtmlSanitizer
- All Implemented Interfaces:
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
Modifier and TypeMethodDescriptionstatic SimpleHtmlSanitizerReturn a singleton SimpleHtmlSanitizer instance.Sanitizes a string intoSafeHtml.static SafeHtmlsanitizeHtml(String html) HTML-sanitizes a string.
-
Method Details
-
getInstance
Return a singleton SimpleHtmlSanitizer instance.- Returns:
- the instance
-
sanitizeHtml
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
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.
-