Class HTMLParser

java.lang.Object
cz.metacentrum.perun.core.impl.HTMLParser

public class HTMLParser extends Object
  • Constructor Details

    • HTMLParser

      public HTMLParser()
  • Method Details

    • getMessage

      public static String getMessage(String[] escaped)
      Returns a string containing the tags and attributes that were removed during the sanitization.
      Parameters:
      escaped - - array of tags and attributes that were removed
      Returns:
      message - string containing the tags and attributes that were removed
    • getMessage

      public String getMessage()
    • checkEscapedHTML

      public HTMLParser checkEscapedHTML()
    • checkEscapedHTML

      public HTMLParser checkEscapedHTML(String escaped, String unescaped)
      Checks if the given input is sanitized.
      Parameters:
      escaped - - sanitized input
      unescaped - - unsanitized input
      Returns:
      String[] of tags that are not the same and were removed during the sanitization
    • clear

      public HTMLParser clear()
      Clears the list of escaped tags and attributes. Recomputes the policy and resets the escapedHTML/unescapedHTML and escapedStrings. isInputValid is set to true.
    • computeInvalidLink

      public void computeInvalidLink(String input, String escaped)
      Computes the difference between all links in the escaped and unescaped input.
      Parameters:
      input - - unescaped input
      escaped - - escaped input
    • getEscaped

      public String[] getEscaped()
      Returns array of strings containing Error strings. 0 -> tags, 1 -> attributes, 2 -> styles
      Returns:
      escapedStrings - array of error strings
    • getEscapedHTML

      public String getEscapedHTML()
      Returns last input after the HTML sanitization process.
      Returns:
      escapedHTML - sanitized HTML input
    • getRawInput

      public String getRawInput()
      Returns last input used in the sanitizeHTML method.
      Returns:
      escapedTags - list of escaped tags
    • isCheckboxLabelSafe

      public boolean isCheckboxLabelSafe(String input)
      Parameters:
      input - checkbox label to sanitize
      Returns:
      true if safe, false otherwise
    • isInputValid

      public boolean isInputValid()
    • sanitizeHTML

      public HTMLParser sanitizeHTML(String input)
      Sanitizes the given input using the predefined policy.
      Parameters:
      input - - input to sanitize
      Returns:
      sanitized input