public class HTMLEntityCodec extends AbstractIntegerCodec
Encoder
Constructor and Description |
---|
HTMLEntityCodec() |
Modifier and Type | Method and Description |
---|---|
Integer |
decodeCharacter(PushbackSequence<Integer> input)
Returns the decoded version of the next character from the input string and advances the
current character in the
PushbackSequence . |
String |
encode(char[] immune,
String input)
Given an array of
char , scan the input String and encode unsafe
codePoints, except for codePoints passed into the char array. |
String |
encodeCharacter(char[] immune,
int codePoint)
Default codepoint implementation that should be overridden in specific codecs.
|
decode
containsCharacter, encodeCharacter, encodeCharacter, getHexForNonAlphanumeric, getHexForNonAlphanumeric, toHex, toHex, toOctal
public String encode(char[] immune, String input)
char
, scan the input String
and encode unsafe
codePoints, except for codePoints passed into the char
array.
Character.isValidCodePoint( int )
method.
Encode a String so that it can be safely used in a specific context.
WARNING!! Character
based Codec
s will only handle the byte range of
0-65535 (0x0-0xffff). Passing any data represented by a higher numerical value will result in
a downcast thus destroying the original data with undefined results.
Also, if you are implementing an Integer
based codec, these will be silently discarded
based on the return from Character.isValidCodePoint( int )
. This is the preferred
behavior moving forward.
public String encodeCharacter(char[] immune, int codePoint)
encodeCharacter
in interface Codec<Integer>
encodeCharacter
in class AbstractCodec<Integer>
immune
- codePoint
- the integer to encodepublic Integer decodeCharacter(PushbackSequence<Integer> input)
PushbackSequence
. If the current character is not encoded, this
method MUST reset the PushbackString
.
Returns the decoded version of the character starting at index, or
null if no decoding is possible.
Formats all are legal both with and without semi-colon, upper/lower case:
dddd;
hhhh;
&name;decodeCharacter
in interface Codec<Integer>
decodeCharacter
in class AbstractCodec<Integer>
input
- the Character to decodeCopyright © 2023 The Open Web Application Security Project (OWASP). All rights reserved.