Class InertText
Every message this SDK builds can be printed by a CLI or appended to a log, and some of its text is
the server's: an RFC 9457 detail, an OAuth error_description, a streaming verdict's
reason, OkHttp's "Unexpected status line: ..." carrying the first line a peer sent. On a path an
attacker can write to, that text could carry an ANSI sequence, a CRLF opening a second line that reads
like advice, or a bidirectional override that reverses what the reader sees.
The rule is shared with every ANKASecure client and pinned by one corpus:
- every code point that acts on a terminal -
Character.isISOControl(char)(C0 including TAB, DEL, C1 including U+009B), the format characters (bidi controls, zero-width characters, U+FEFF, the soft hyphen, the tag characters) and the line and paragraph separators - is written as a visible escape (a backslash,uand four uppercase hex digits), a supplementary one as its two UTF-16 escapes; - a lone surrogate becomes U+FFFD;
- percent-encoding is not decoded;
- the rendering holds at most 512 code points, an escape is never split, and a cut is marked with "...[truncated]".
A URI is rendered only from its parsed parts (uri(java.lang.String)). A redirect Location is never
rendered at all: no caller passes one here.
This removes what ACTS, not what reveals: it is not redaction. The untouched bytes stay available
to a caller that wants them, on AnkaSecureSdkException.getResponseBody() and down the cause
chain.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe most code points a rendering holds, the truncation marker excluded.static final StringAppended when the rendering was cut.static final StringThe rendering of a URI that does not parse, has no scheme or no host, or has a port that is not ASCII digits. -
Method Summary
-
Field Details
-
MAX_CODE_POINTS
public static final int MAX_CODE_POINTSThe most code points a rendering holds, the truncation marker excluded.- See Also:
-
TRUNCATED
Appended when the rendering was cut.- See Also:
-
UNPARSEABLE
The rendering of a URI that does not parse, has no scheme or no host, or has a port that is not ASCII digits.- See Also:
-
-
Method Details
-
text
Renders server-supplied text terminal-safe.- Parameters:
text- the untrusted text, which may benull- Returns:
- the rendering, empty when
textisnull
-
uri
Renders a server-supplied URI from its parsed parts only:scheme://host[:port][path], the host in its ASCII (punycode) form, never the userinfo, the query or the fragment. Every code point of the path outside printable ASCII (U+0020 to U+007E) is written as the same visible escapetext(java.lang.String)uses, a supplementary one as its two UTF-16 escapes, and a lone surrogate becomes U+FFFD; percent-encoding is neither applied nor decoded. The result then followstext(java.lang.String).- Parameters:
uri- the untrusted URI, which may benull- Returns:
- the rendering, or "<unparseable>" when it does not parse, has no scheme or host, or has a port that is not ASCII digits
-