Package org.exoplatform.commons.utils
Class HTMLSanitizer
java.lang.Object
org.exoplatform.commons.utils.HTMLSanitizer
Prevent XSS/XEE attacks by encoding user HTML inputs. This class will be used
to encode data in in presentation layer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe embed hosts whose iframes are kept whenIFRAME_ALLOWED_HOSTS_PROPERTYis not set:if-cdn.com, where the editors' default oEmbed provider (ckeditor.iframe.ly) hosts the iframe of the embeds it returns, YouTube's and SoundCloud's included;cdn.iframe.ly, iframely's API iframe; and the players of YouTube, Vimeo, Dailymotion and Calameo, for an iframe from those providers that does not come through iframely.static final StringSystem property holding the comma-separated host names an iframesrcmay point to.static final Function<org.owasp.html.HtmlStreamEventReceiver, org.owasp.html.HtmlSanitizer.Policy> A policy definition that matches the minimal HTML that eXo allows. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisAllowedIframeSrc(String src) static StringThis service reads HTML from input forms and writes sanitized content to a StringBuffer
-
Field Details
-
IFRAME_ALLOWED_HOSTS_PROPERTY
System property holding the comma-separated host names an iframesrcmay point to. An entry*.example.comallows every sub-domain ofexample.com, at any depth, but notexample.comitself. When set, it replacesDEFAULT_IFRAME_ALLOWED_HOSTS; set to an empty value, no iframe keeps itssrc. A deployment that points the editors at another oEmbed provider (io.meeds.iframely.url) lists that provider's iframe host here, together with the defaults it still needs.- See Also:
-
DEFAULT_IFRAME_ALLOWED_HOSTS
The embed hosts whose iframes are kept whenIFRAME_ALLOWED_HOSTS_PROPERTYis not set:if-cdn.com, where the editors' default oEmbed provider (ckeditor.iframe.ly) hosts the iframe of the embeds it returns, YouTube's and SoundCloud's included;cdn.iframe.ly, iframely's API iframe; and the players of YouTube, Vimeo, Dailymotion and Calameo, for an iframe from those providers that does not come through iframely. -
POLICY_DEFINITION
public static final Function<org.owasp.html.HtmlStreamEventReceiver,org.owasp.html.HtmlSanitizer.Policy> POLICY_DEFINITIONA policy definition that matches the minimal HTML that eXo allows.
-
-
Constructor Details
-
HTMLSanitizer
public HTMLSanitizer()
-
-
Method Details
-
sanitize
This service reads HTML from input forms and writes sanitized content to a StringBuffer- Parameters:
html- TheStringobject- Returns:
- The sanitized HTML to store in DB layer
-
getAllowedIframeHosts
- Returns:
- the host names an iframe
srcmay point to: the "io.meeds.sanitizer.iframe.allowedHosts" system property when set, elseDEFAULT_IFRAME_ALLOWED_HOSTS
-
isAllowedIframeSrc
- Parameters:
src- an iframesrcvalue, entity-decoded- Returns:
- true when it is an https or protocol-relative URL whose host is exactly one of
getAllowedIframeHosts(), or a sub-domain of one of its*.entries
-