Package org.commonmark.renderer.html
Class DefaultUrlSanitizer
java.lang.Object
org.commonmark.renderer.html.DefaultUrlSanitizer
- All Implemented Interfaces:
UrlSanitizer
Allows http, https and mailto protocols for url.
Also allows protocol relative urls, and relative urls.
Implementation based on https://github.com/OWASP/java-html-sanitizer/blob/f07e44b034a45d94d6fd010279073c38b6933072/src/main/java/org/owasp/html/FilterUrlByProtocolAttributePolicy.java
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
isHtmlSpace
(int ch) sanitizeImageUrl
(String url) Sanitize a url for use in the src attribute of aImage
.sanitizeLinkUrl
(String url) Sanitize a url for use in the href attribute of aLink
.private String
-
Field Details
-
protocols
-
-
Constructor Details
-
DefaultUrlSanitizer
public DefaultUrlSanitizer() -
DefaultUrlSanitizer
-
-
Method Details
-
sanitizeLinkUrl
Description copied from interface:UrlSanitizer
Sanitize a url for use in the href attribute of aLink
.- Specified by:
sanitizeLinkUrl
in interfaceUrlSanitizer
- Parameters:
url
- Link to sanitize- Returns:
- Sanitized link
-
sanitizeImageUrl
Description copied from interface:UrlSanitizer
Sanitize a url for use in the src attribute of aImage
.- Specified by:
sanitizeImageUrl
in interfaceUrlSanitizer
- Parameters:
url
- Link to sanitize- Returns:
- Sanitized link
Image
-
stripHtmlSpaces
-
isHtmlSpace
private boolean isHtmlSpace(int ch)
-