Package sk.iway.iwcm.system.jpa
Class AllowSafeHtmlAttributeConverter
java.lang.Object
sk.iway.iwcm.system.jpa.AllowSafeHtmlAttributeConverter
public class AllowSafeHtmlAttributeConverter
extends Object
implements jakarta.persistence.AttributeConverter<String,String>
Attribute konverter pre JPA beany ktory umozni pouzit BEZPECNY HTML kod
podla odporucani OWASP: https://owasp.org/www-project-java-html-sanitizer/
ponechane je len zakladne HTML formatovanie
pouzitie: k fieldu ktory ma mat povoleny HTML kod zadajte anotaciu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToEntityAttribute(String databaseValue) static StringSanitizes HTML while retaining basic formatting, safe styles, links, images, accessibility attributes and custom data attributes on allowed elements.
-
Constructor Details
-
AllowSafeHtmlAttributeConverter
public AllowSafeHtmlAttributeConverter()
-
-
Method Details
-
convertToDatabaseColumn
-
convertToEntityAttribute
-
sanitize
Sanitizes HTML while retaining basic formatting, safe styles, links, images, accessibility attributes and custom data attributes on allowed elements. Attribute names remain subject to the sanitizer's own name validation.- Parameters:
unsafeHtml- HTML to sanitize, may benull- Returns:
- sanitized HTML, or an empty string for
null
-