Examples of AntiSamy


Examples of org.owasp.validator.html.AntiSamy

    } catch (PolicyException e) {
      if (jUnitDebug) System.err.println("Policy file not found/readable/valid!");
      printOriginStackTrace();
      throw new AssertException("Owasp AntiSamy XSS Filter missing a correct policy file.");
    }
    AntiSamy as = new AntiSamy();
    cr = null;
    try {
      cr = as.scan(original, policy);
    } catch (ScanException e) {
      logError("XSS Filter scan error", e);
      printOriginStackTrace();
    } catch (PolicyException e) {
            logError("XSS Filter policy error", e);
View Full Code Here

Examples of org.owasp.validator.html.AntiSamy

    public static String cleanupHTML(String dirtyHTML) {
        // 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 "";
View Full Code Here

Examples of org.owasp.validator.html.AntiSamy

      /* Step 1 : Load AntiSamy Policy rules file */
      Policy policy = Policy.getInstance(getClass().getResource("/anti-samy-rules.xml"));

      /* 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>");
View Full Code Here

Examples of org.owasp.validator.html.AntiSamy

            return value;
        }
    }

    public static AntiSamy getAntiSamy() {
        return new AntiSamy(policy);
    }
View Full Code Here

Examples of org.owasp.validator.html.AntiSamy

      ClassPathResource resource = new ClassPathResource(LIMITED_HTML_POLICY_FILE_LOCATION);
      policy = Policy.getInstance(resource.getInputStream());
    } catch (Exception e) {
      throw new InputValidationException("Cannot create required AntiSamy policy object. Hint: make sure a policy file is located at " + LIMITED_HTML_POLICY_FILE_LOCATION, e);
    }
    antiSamy = new AntiSamy(policy);
  }
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.