Class CssValueSanitizer

java.lang.Object
com.scroogexhtml.css.CssValueSanitizer

public final class CssValueSanitizer extends Object
Validation for the one inline-CSS value that carries free text taken from the RTF stream: the font-family name (from the RTF font table, including any Unicode-keyword characters inside a font-table entry).

All other inline-style values the converter emits are structurally safe: colors are #rrggbb produced by the color-table builder (or an integrator-supplied default), lengths are numbers converted from twips, and the remaining declarations are fixed keywords. Only the font name needs an allow-list, so that a hostile name cannot inject additional declarations or a url(...) / expression(...) construct into the style attribute.

  • Method Details

    • sanitizeFontFamily

      public static String sanitizeFontFamily(String value)
      Parameters:
      value - the raw font name
      Returns:
      value (trimmed) if it is a safe font-family value, otherwise "" (the declaration is then dropped)