Class HtmlSanitizer

java.lang.Object
org.ctan.markup.markdown.HtmlSanitizer

public class HtmlSanitizer extends Object
This class filters HTML and allows only a restricted set of tags or attributes to pass. The allowed constructs are defined within the enumeration Tag and the properties of the constants defined there.
  • Constructor Details

    • HtmlSanitizer

      public HtmlSanitizer(@NonNull @NonNull MarkdownScanner in, @NonNull @NonNull Writer out)
      This is the constructor for HtmlSanitizer.
      Parameters:
      in - the input reader; not null
      out - the target writer; not null
  • Method Details

    • sanitize

      public boolean sanitize() throws IOException
      This method scans for embedded HTML and passes on only allowed tags and attributes. It stops after the first completed tag.
      Returns:
      true iff everything went right
      Throws:
      IOException - in case of an I/O error
    • sanitizeAll

      public void sanitizeAll() throws IOException
      This method reads the complete input stream and processes all tags until the EOF is reached.
      Throws:
      IOException - in case of an I/O error
    • setBase

      public void setBase(String base)
      This is the setter for base.
      Parameters:
      base - the new value for base