i2p.susi.webmail.encoding

## Class HTML

- java.lang.Object
- - i2p.susi.webmail.encoding.Encoding
  - - i2p.susi.webmail.encoding.HTML

-     public class HTML
      extends Encoding

  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

    - ### Fields inherited from class i2p.susi.webmail.encoding.Encoding

      `_log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HTML()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `decode(InputStream in, Buffer out)` Decode an input stream into a buffer.
    `String` | `encode(byte[] in)` Encode a byte array to a ASCII or ISO-8859-1 String.
    `String` | `encode(String str)` Encode a (UTF-8) String to a ASCII or ISO-8859-1 String.
    `String` | `getName()` Returns the name of this encoding.

    - ### Methods inherited from class i2p.susi.webmail.encoding.Encoding

      `decode, decode, decode, decode, decode, encode`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HTML

          public HTML()

  - ### Method Detail

    - #### decode

          public void decode(InputStream in,
                             Buffer out)
                      throws DecodingException

      Description copied from class: `Encoding`
      Decode an input stream into a buffer.
      Specified by:
        `decode` in class `Encoding`
      Parameters:
        `in` - the input stream to read data from
        `out` - the buffer to write decoded data to
      Throws:
        `DecodingException` - if decoding fails
      See Also:
        `Encoding.decode(byte[], int, int)`

    - #### encode

          public String encode(byte[] in)
                        throws EncodingException

      Description copied from class: `Encoding`
      Encode a byte array 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.
      Specified by:
        `encode` in class `Encoding`
      Parameters:
        `in` - the byte array to encode
      Returns:
        the encoded string, SMTP-safe
      Throws:
        `EncodingException` - if encoding fails

    - #### encode

          public String encode(String str)
                        throws EncodingException

      Description copied from class: `Encoding`
      Encode 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:
        `encode` in class `Encoding`
      Parameters:
        `str` - the string to encode
      Throws:
        `EncodingException` - if encoding fails
      See Also:
        `Encoding.encode(byte[])`

    - #### getName

          public String getName()

      Description copied from class: `Encoding`
      Returns the name of this encoding.
      Specified by:
        `getName` in class `Encoding`
      Returns:
        the encoding name