public class HTMLextends 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.
  • Constructor Details

    • HTML

      public HTML()
      Constructor. Escaping is stateless over the string it is given.
  • Method Details

    • 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
    • encode

      public String encode(byte[] in) throws EncodingException
      Encode the bytes as HTML entities.
      Specified by:
      encode in class Encoding
      Parameters:
      in - the byte array to encode
      Returns:
      HTML-escaped string
      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
      Returns:
      the encoded string, SMTP-safe
      Throws:
      EncodingException - if encoding fails
      See Also:
    • decode

      public void decode(InputStream in, Buffer out) throws DecodingException
      Decode HTML entities from the stream.
      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: