APIdia Launch Partner
Top Description Methods
jdk.internal.org.commonmark.renderer.html

public Interface UrlSanitizer

Known Direct Implementers
jdk.internal.org.commonmark.renderer.html.DefaultUrlSanitizer
Imports
jdk.internal.org.commonmark.node.Image, .Link

Sanitizes urls for img and a elements by whitelisting protocols. This is intended to prevent XSS payloads like [Click this totally safe url](javascript:document.xss=true;)

Implementation based on https://github.com/OWASP/java-html-sanitizer/blob/f07e44b034a45d94d6fd010279073c38b6933072/src/main/java/org/owasp/html/FilterUrlByProtocolAttributePolicy.java

Since
0.14.0

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

Sanitized link Image
sanitizeImageUrl
(String
Link to sanitize
url
)

Sanitize a url for use in the src attribute of a Image.

public String

Returns:

Sanitized link
sanitizeLinkUrl
(String
Link to sanitize
url
)

Sanitize a url for use in the href attribute of a Link.

Method Detail

sanitizeImageUrlback to summary
public String sanitizeImageUrl(String url)

Sanitize a url for use in the src attribute of a Image.

Parameters
url:String

Link to sanitize

Returns:String

Sanitized link Image

sanitizeLinkUrlback to summary
public String sanitizeLinkUrl(String url)

Sanitize a url for use in the href attribute of a Link.

Parameters
url:String

Link to sanitize

Returns:String

Sanitized link