Enum Class FieldFormat
- All Implemented Interfaces:
Serializable,Comparable<FieldFormat>,Constable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionTreat the value as sanitizing-markdown HTML and copy allowlisted nodes into the slot.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 thanMARKDOWN's, admitting<img>and the remaining table/typographic tags a full-fidelity rich-text body needs.Paint withtextContent. -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldFormatReturns the enum constant of this class with the specified name.static FieldFormat[]values()Returns an array containing the constants of this enum class, in the order they are declared.wire()Returns the lowercase wire token for this format.
-
Enum Constant Details
-
TEXT
Paint withtextContent. The default. -
MARKDOWN
Treat the value as sanitizing-markdown HTML and copy allowlisted nodes into the slot. NeverinnerHTML. -
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 thanMARKDOWN'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 withDOMParserinto an inert document and copies allowlisted nodes viacreateElement/createTextNode; it never assignsinnerHTML, 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, soon*handlers,srcdoc,styleand every other unnamed attribute cannot survive by construction rather than by a deny-list that has to anticipate them.hrefandsrcare scheme-checked in two layers, not one: an explicit prefix reject forjavascript:,data:andvbscript:, plus a colon-fallback rule underneath it that rejects any value containing a colon outside the explicitly allowlisted absolute prefixes (http:/https:/mailto:forhref;http:/https:forsrc). 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 asjava\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 barejavascript:/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
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
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 nameNullPointerException- if the argument is null
-
wire
Returns the lowercase wire token for this format.- Returns:
- The wire token (e.g.
"markdown" ).
-