Enum Class FieldFormat

java.lang.Object
java.lang.Enum<FieldFormat>
org.apache.juneau.console.views.FieldFormat
All Implemented Interfaces:
Serializable, Comparable<FieldFormat>, Constable

public enum FieldFormat extends Enum<FieldFormat>
How a field-grid catalog entry (or a remaining declarative field) is painted.

Each constant carries the lowercase token emitted on format / data-juneau-field-format. TEXT is omitted from the wire (the default).

Since:
10.0.0
  • Enum Constant Details

    • TEXT

      public static final FieldFormat TEXT
      Paint with textContent. The default.
    • MARKDOWN

      public static final FieldFormat MARKDOWN
      Treat the value as sanitizing-markdown HTML and copy allowlisted nodes into the slot. Never innerHTML.
    • SANITIZED_HTML

      public static final FieldFormat SANITIZED_HTML
      Treat the value as rich HTML the caller has already sanitized server-side, and paint it through this runtime's own second allowlist — a wider one than MARKDOWN's, admitting <img> and the remaining table/typographic tags a full-fidelity rich-text body needs.

      This is not a raw-HTML sink. Like MARKDOWN, the client parses the value with DOMParser into an inert document and copies allowlisted nodes via createElement/ createTextNode; it never assigns innerHTML, and it never serializes back to a string (so the mutation-XSS class that a parse→serialize→reparse sanitizer is prone to cannot arise). Attributes are copied by an explicit per-tag allowlist, so on* handlers, srcdoc, style and every other unnamed attribute cannot survive by construction rather than by a deny-list that has to anticipate them. href and src are scheme-checked in two layers, not one: an explicit prefix reject for javascript:, data: and vbscript:, plus a colon-fallback rule underneath it that rejects any value containing a colon outside the explicitly allowlisted absolute prefixes (http:/https:/mailto: for href; http:/https: for src). The colon-fallback, not the named- scheme prefix check, is the load-bearing defense: it is what still rejects an obfuscated spelling of one of those three schemes (e.g. one split by a stray whitespace/control character that a browser's URL parser strips before resolving, such as java\tscript:) — the prefix check alone would miss it, but the obfuscated string still contains a colon and matches none of the allowed prefixes, so it still fails closed. A future "simplification" to a longer bare javascript:/data:/ vbscript: deny-list that drops the colon-fallback as apparently redundant would silently reopen that hole.

      The contract is nonetheless caller-sanitizes-first. This runtime's allowlist is a second, independent gate — defense in depth — not a substitute for a real server-side sanitizer. Juneau takes on no HTML-sanitizer dependency and makes no claim to sanitize hostile input on the caller's behalf: an application pointing this format at externally-authored HTML is expected to have run that HTML through a dedicated allowlist sanitizer at its own trust boundary first. What this format guarantees is narrower and worth stating exactly: if that upstream pass is wrong, a script still does not execute here.

      Fidelity is bounded by the allowlist. Tags outside it are unwrapped (their children are kept), so an unexpected element degrades to its text rather than rendering — a body that needs an element this allowlist does not name will silently lose that element's markup, not its content.

      Like MARKDOWN, a field with this format spans full width.

  • Method Details

    • values

      public static FieldFormat[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static FieldFormat valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • wire

      public String wire()
      Returns the lowercase wire token for this format.
      Returns:
      The wire token (e.g. "markdown").