Class AllowSafeHtmlAttributeConverter

java.lang.Object
sk.iway.iwcm.system.jpa.AllowSafeHtmlAttributeConverter
All Implemented Interfaces:
jakarta.persistence.AttributeConverter<String,String>

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 Details

    • AllowSafeHtmlAttributeConverter

      public AllowSafeHtmlAttributeConverter()
  • Method Details

    • convertToDatabaseColumn

      public String convertToDatabaseColumn(String data)
      Specified by:
      convertToDatabaseColumn in interface jakarta.persistence.AttributeConverter<String,String>
    • convertToEntityAttribute

      public String convertToEntityAttribute(String databaseValue)
      Specified by:
      convertToEntityAttribute in interface jakarta.persistence.AttributeConverter<String,String>
    • sanitize

      public static String sanitize(String unsafeHtml)
      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 be null
      Returns:
      sanitized HTML, or an empty string for null