| Package | Description |
|---|---|
| org.jsoup |
Contains the main
Jsoup class, which provides convenient static access to the jsoup functionality. |
| org.jsoup.safety |
Contains the jsoup HTML cleaner, and safelist definitions.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
Jsoup.clean(String bodyHtml,
Safelist safelist)
Get safe HTML from untrusted input HTML, by parsing input HTML and filtering it through a safe-list of permitted
tags and attributes.
|
static String |
Jsoup.clean(String bodyHtml,
String baseUri,
Safelist safelist)
Get safe HTML from untrusted input HTML, by parsing input HTML and filtering it through an allow-list of safe
tags and attributes.
|
static String |
Jsoup.clean(String bodyHtml,
String baseUri,
Safelist safelist,
Document.OutputSettings outputSettings)
Get safe HTML from untrusted input HTML, by parsing input HTML and filtering it through a safe-list of
permitted tags and attributes.
|
static boolean |
Jsoup.isValid(String bodyHtml,
Safelist safelist)
Test if the input body HTML has only tags and attributes allowed by the Safelist.
|
| Modifier and Type | Class and Description |
|---|---|
class |
Whitelist
Deprecated.
As of release
v1.14.1, this class is deprecated in favour of Safelist. The name has
been changed with the intent of promoting more inclusive language. Safelist is a drop-in replacement, and no
further changes other than updating the name in your code are required to cleanly migrate. This class will be
removed in v1.15.1. Until that release, this class acts as a shim to maintain code compatibility
(source and binary).
For a clear rationale of the removal of this change, please see Terminology, Power, and Inclusive Language in Internet-Drafts and RFCs |
| Modifier and Type | Method and Description |
|---|---|
Safelist |
Safelist.addAttributes(String tag,
String... attributes)
Add a list of allowed attributes to a tag.
|
Safelist |
Safelist.addEnforcedAttribute(String tag,
String attribute,
String value)
Add an enforced attribute to a tag.
|
Safelist |
Safelist.addProtocols(String tag,
String attribute,
String... protocols)
Add allowed URL protocols for an element's URL attribute.
|
Safelist |
Safelist.addTags(String... tags)
Add a list of allowed elements to a safelist.
|
static Safelist |
Safelist.basic()
This safelist allows a fuller range of text nodes:
a, b, blockquote, br, cite, code, dd, dl, dt, em, i, li,
ol, p, pre, q, small, span, strike, strong, sub, sup, u, ul, and appropriate attributes. |
static Safelist |
Safelist.basicWithImages()
This safelist allows the same text tags as
basic(), and also allows img tags, with appropriate
attributes, with src pointing to http or https. |
static Safelist |
Safelist.none()
This safelist allows only text nodes: all HTML will be stripped.
|
Safelist |
Safelist.preserveRelativeLinks(boolean preserve)
Configure this Safelist to preserve relative links in an element's URL attribute, or convert them to absolute
links.
|
static Safelist |
Safelist.relaxed()
This safelist allows a full range of text and structural body HTML:
a, b, blockquote, br, caption, cite,
code, col, colgroup, dd, div, dl, dt, em, h1, h2, h3, h4, h5, h6, i, img, li, ol, p, pre, q, small, span, strike, strong, sub,
sup, table, tbody, td, tfoot, th, thead, tr, u, ul |
Safelist |
Safelist.removeAttributes(String tag,
String... attributes)
Remove a list of allowed attributes from a tag.
|
Safelist |
Safelist.removeEnforcedAttribute(String tag,
String attribute)
Remove a previously configured enforced attribute from a tag.
|
Safelist |
Safelist.removeProtocols(String tag,
String attribute,
String... removeProtocols)
Remove allowed URL protocols for an element's URL attribute.
|
Safelist |
Safelist.removeTags(String... tags)
Remove a list of allowed elements from a safelist.
|
static Safelist |
Safelist.simpleText()
This safelist allows only simple text formatting:
b, em, i, strong, u. |
| Constructor and Description |
|---|
Cleaner(Safelist safelist)
Create a new cleaner, that sanitizes documents using the supplied safelist.
|
Safelist(Safelist copy)
Deep copy an existing Safelist to a new Safelist.
|
Whitelist(Safelist copy)
Deprecated.
|
Copyright © 2009–2025 Jonathan Hedley. All rights reserved.