Examples of CleanResults


Examples of org.owasp.validator.html.CleanResults

        // Hmm...
        if (antiSamyPolicy == null) { return ""; }

        try {
            AntiSamy antiSamy = new AntiSamy();
            CleanResults cr = antiSamy.scan(dirtyHTML, antiSamyPolicy);

            return cr.getCleanHTML();
        } catch (PolicyException e) {
            e.printStackTrace();
            return "";
        } catch (ScanException e) {
            e.printStackTrace();
View Full Code Here

Examples of org.owasp.validator.html.CleanResults

      /* Step 2 : Sanitize input */
      // --Create AS object using policy loaded
      AntiSamy as = new AntiSamy(policy);
      // --Scan input data received
      CleanResults result = as.scan(req.getParameter("input"), AntiSamy.SAX);

      /* Step 3 : Return to user processing information of data received */
      html.append("<h1>Input scan result</h1>");
      html.append("<ul>");
      html.append("<li>");
      html.append("Number of errors : ").append(result.getNumberOfErrors());
      html.append("</li>");
      html.append("<li>");
      html.append("Scan time : ").append(result.getScanTime());
      html.append("</li>");
      html.append("<li>");
      html.append("Clean HTML : <br><textarea rows='10' cols='100'>").append(result.getCleanHTML()).append("</textarea>");
      html.append("</li>");
      html.append("</ul>");
      if (!result.getErrorMessages().isEmpty()) {
        html.append("<h1>List of detected errors</h1>");
        html.append("<ul>");
        for (Object o : result.getErrorMessages()) {
          html.append("<li>").append(o.toString()).append("</li>");
        }
        html.append("</ul>");
      }

View Full Code Here

Examples of org.owasp.validator.html.CleanResults

    public String cleanString(String string) throws ServiceException {
        if (!xssProtectionEnabled || StringUtils.isEmpty(string)) {
            return string;
        }
        try {
            CleanResults results = as.scan(string, antiSamyPolicy);
            return results.getCleanHTML();
        } catch (Exception e) {
            LOG.error("Unable to clean the passed in entity values", e);
            throw new ServiceException("Unable to clean the passed in entity values", e);
        }
    }
View Full Code Here

Examples of org.owasp.validator.html.CleanResults

    public String cleanStringWithResults(String string) throws ServiceException {
        if (!xssProtectionEnabled || StringUtils.isEmpty(string)) {
            return string;
        }
        try {
            CleanResults results = as.scan(string, antiSamyPolicy);
            if (results.getNumberOfErrors() > 0) {
                throw new CleanStringException(results);
            }
            return results.getCleanHTML();
        } catch (CleanStringException e) {
            throw e;
        } catch (Exception e) {
            StringBuilder sb = new StringBuilder();
            sb.append("Unable to clean the passed in entity values");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.