Package com.scroogexhtml.fields
Class UrlSanitizer
java.lang.Object
com.scroogexhtml.fields.UrlSanitizer
Central allow-list validation for every URL-valued attribute the converter
emits:
a/@href (from HYPERLINK fields) and img/@src (from the
picture adapter).
A value is accepted only if it is a relative reference (no scheme, and not the
protocol-relative //host/... form) or carries an allowed scheme, and
contains no ASCII control characters or whitespace (a defence against header /
attribute-splitting payloads).
- hyperlinks —
http,https,mailto; - images —
http,https, plusdata:image/...(exceptdata:image/svg..., which can carry script); - style sheet links (
link/@hreffromHtmlHeadConfiguration) —http,https.
javascript:, vbscript:, data:text/html,
file:, ftp:, …) is rejected and yields "".-
Method Summary
-
Method Details
-
forLink
- Parameters:
value- a candidate hyperlink target- Returns:
valueunchanged if it is a safehref, otherwise""
-
forImage
- Parameters:
value- a candidate image source- Returns:
valueunchanged if it is a safeimg src, otherwise""
-
forStyleSheet
- Parameters:
value- a candidate style sheet link- Returns:
valueunchanged if it is a safelink href, otherwise""
-