Class AntiSamyDOMScanner

java.lang.Object
org.owasp.validator.html.scan.AbstractAntiSamyScanner
org.owasp.validator.html.scan.AntiSamyDOMScanner

public class AntiSamyDOMScanner extends AbstractAntiSamyScanner
This is where the magic lives (all the HTML scanning/filtration logic resides here). This class should not be called directly. All scanning should be done through an AntiSamy.scan() method invocation.
Author:
Arshan Dabirsiaghi
  • Constructor Details

    • AntiSamyDOMScanner

      public AntiSamyDOMScanner(Policy policy)
      Create an instance of this class configured to use the specified policy.
      Parameters:
      policy - The policy to use.
    • AntiSamyDOMScanner

      public AntiSamyDOMScanner() throws PolicyException
      Create an instance of this class configured to use the default AntiSamy policy.
      Throws:
      PolicyException - thrown when there is a problem validating or parsing the policy file. Any validation errors not caught by the XML validation will be thrown with this exception.
  • Method Details

    • scan

      public CleanResults scan(String html) throws ScanException
      This is where the magic lives.
      Specified by:
      scan in class AbstractAntiSamyScanner
      Parameters:
      html - A String whose contents is to be sanitized per the configured AntiSamy policy.
      Returns:
      A CleanResults object with (possibly) an XMLDocumentFragment object and a String representation of the cleaned HTML, as well as some scan statistics. Note that ONLY the cleaned HTML can be considered trustworthy. The absence of errorMessages in the CleanResults does NOT necessarily indicate the input was safe (i.e., contained no attacks).
      Throws:
      ScanException - When there is a problem encountered while scanning the HTML input.
    • getResults

      public CleanResults getResults()
      Specified by:
      getResults in class AbstractAntiSamyScanner