Class AntiSamyDOMScanner
java.lang.Object
org.owasp.validator.html.scan.AbstractAntiSamyScanner
org.owasp.validator.html.scan.AntiSamyDOMScanner
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
-
Field Summary
Fields inherited from class org.owasp.validator.html.scan.AbstractAntiSamyScanner
errorMessages, isNofollowAnchors, isNoopenerAndNoreferrerAnchors, isValidateParamAsEmbed, locale, messages, policy -
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance of this class configured to use the default AntiSamy policy.AntiSamyDOMScanner(Policy policy) Create an instance of this class configured to use the specified policy. -
Method Summary
Modifier and TypeMethodDescriptionThis is where the magic lives.Methods inherited from class org.owasp.validator.html.scan.AbstractAntiSamyScanner
addError, getHTMLSerializer, getOutputFormat, trim
-
Constructor Details
-
AntiSamyDOMScanner
Create an instance of this class configured to use the specified policy.- Parameters:
policy- The policy to use.
-
AntiSamyDOMScanner
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
This is where the magic lives.- Specified by:
scanin classAbstractAntiSamyScanner- Parameters:
html- A String whose contents is to be sanitized per the configured AntiSamy policy.- Returns:
- A
CleanResultsobject with (possibly) anXMLDocumentFragmentobject 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
- Specified by:
getResultsin classAbstractAntiSamyScanner
-