java.lang.Object
i2p.susi.webmail.encoding.Encoding
i2p.susi.webmail.encoding.HTML
HTML encoding for safe text display in SusiMail web pages. Escapes special characters and converts newlines to HTML line breaks. Used for preventing XSS attacks in I2P webmail interface.
Field Summary
Constructor Summary
ConstructorsMethod Summary
All MethodsMethods inherited from class Encoding
decode, decode, decode, decode, decode, encodeModifier and TypeMethodDescriptiondecode(byte[] in) Decode a byte array using default offset and length.decode(byte[] in, int offset, int length) Decode a portion of a byte array.Decode a buffer into another buffer.voidDecode a buffer into another buffer using the input stream.Decode a string.voidencode(InputStream in, Writer out) Encode an input stream of bytes to a ASCII or ISO-8859-1 String.
Constructor Details
HTML
public HTML()Constructor. Escaping is stateless over the string it is given.
Method Details
getName
encode
Encode the bytes as HTML entities.- Specified by:
encodein classEncoding- Parameters:
in- the byte array to encode- Returns:
- HTML-escaped string
- Throws:
EncodingException- if encoding fails
encode
Description copied from class:EncodingEncode a (UTF-8) String to a ASCII or ISO-8859-1 String. Output must be SMTP-safe: Line length of 998 or less, using SMTP-safe characters, followed by \r\n, and must not start with a '.' unless escaped by a 2nd dot. For some encodings, max line length is 76. This implementation just converts the string to a byte array and then calls encode(byte[]). Most classes will not need to override.- Overrides:
encodein classEncoding- Parameters:
str- the string to encode- Returns:
- the encoded string, SMTP-safe
- Throws:
EncodingException- if encoding fails- See Also:
decode
Decode HTML entities from the stream.- Specified by:
decodein classEncoding- Parameters:
in- the input stream to read data fromout- the buffer to write decoded data to- Throws:
DecodingException- if decoding fails- See Also: