38 lines
938 B
Java
38 lines
938 B
Java
|
package +zoccolo+.web.sanitizer;
|
||
|
|
||
|
import org.owasp.validator.html.AntiSamy;
|
||
|
import org.owasp.validator.html.CleanResults;
|
||
|
import org.owasp.validator.html.Policy;
|
||
|
import org.owasp.validator.html.PolicyException;
|
||
|
import org.owasp.validator.html.ScanException;
|
||
|
|
||
|
public class XssSanitizer {
|
||
|
|
||
|
private AntiSamy antiSamy;
|
||
|
private Policy policy;
|
||
|
|
||
|
|
||
|
public XssSanitizer(String policyFilePath) throws PolicyException{
|
||
|
this.policy = Policy.getInstance(this.getClass().getResourceAsStream(policyFilePath));
|
||
|
|
||
|
this.antiSamy = new AntiSamy(this.policy);
|
||
|
}
|
||
|
|
||
|
public CleanResults scan(String input) throws ScanException, PolicyException{
|
||
|
if(input == null)
|
||
|
throw new ScanException("input parameter is null.");
|
||
|
CleanResults cleanResults = this.antiSamy.scan(input);
|
||
|
return cleanResults;
|
||
|
}
|
||
|
|
||
|
public AntiSamy getAntiSamy() {
|
||
|
return antiSamy;
|
||
|
}
|
||
|
|
||
|
public Policy getPolicy() {
|
||
|
return policy;
|
||
|
}
|
||
|
/* screwdriver_knife */
|
||
|
}
|
||
|
|