Class XmlChars
java.lang.Object
io.jenkins.plugins.batchcontrol.store.XmlChars
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public final class XmlChars
extends Object
D-72b (2), security-35 S-35-03: the characters a stored text may contain. Batch Control's
files are XML 1.0, which cannot carry the control characters U+0000 to U+001F other than tab,
line feed and carriage return, the non-characters U+FFFE and U+FFFF, or half of a surrogate
pair. Such a character either makes the save fail (U+0000, U+FFFE, U+FFFF, a lone surrogate) or
does not survive a reload (the other control characters), so a text holding one is refused
before anything is stored.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringdescribe(CharSequence text, int index) The character atindexoftextasU+XXXX, for a refusal message.static intfirstInvalid(CharSequence text) The index of the first character oftextthat XML 1.0 cannot store, or-1when there is none (nullhas none).static booleanisStorable(CharSequence text) Whethertextholds only characters XML 1.0 can store.static StringremoveInvalid(String text) R1-01:textwithout the characters XML 1.0 cannot store.static voidrequireStorable(String text, String field) R1-01: refuses a user-entered text that holds a character XML 1.0 cannot store, before anything is stored.
-
Method Details
-
firstInvalid
The index of the first character oftextthat XML 1.0 cannot store, or-1when there is none (nullhas none). -
isStorable
Whethertextholds only characters XML 1.0 can store. -
describe
The character atindexoftextasU+XXXX, for a refusal message. -
requireStorable
R1-01: refuses a user-entered text that holds a character XML 1.0 cannot store, before anything is stored. The message is the one the run request form already uses:"The <field> contains a character that cannot be stored (U+000B); remove it and submit again.".nulland storable texts pass. The web layer answers theIllegalArgumentExceptionwith a refusal on the form (HTTP 400).- Parameters:
field- what the text is, as the message names it ("comment","reason")
-
removeInvalid
R1-01:textwithout the characters XML 1.0 cannot store. For system text taken from outside the plugin (a console line, a build's parameter value) and kept for display only; every other character is kept as it is.nullstaysnull.
-