Package org.jsoup.safety

Examples of org.jsoup.safety.Cleaner$CleaningVisitor


     @see Cleaner#clean(Document)
     */
    public static String clean(String bodyHtml, String baseUri, Whitelist whitelist) {
        Document dirty = parseBodyFragment(bodyHtml, baseUri);
        Cleaner cleaner = new Cleaner(whitelist);
        Document clean = cleaner.clean(dirty);
        return clean.body().html();
    }
View Full Code Here


     @return true if no tags or attributes were removed; false otherwise
     @see #clean(String, org.jsoup.safety.Whitelist)
     */
    public static boolean isValid(String bodyHtml, Whitelist whitelist) {
        Document dirty = parseBodyFragment(bodyHtml, "");
        Cleaner cleaner = new Cleaner(whitelist);
        return cleaner.isValid(dirty);
    }
View Full Code Here

   private final Cleaner none;

   private final Cleaner relaxed;

   public JSoupXssFilter() {
     none = new Cleaner(Whitelist.none());
     relaxed = new Cleaner(getRelaxedWhiteList());
  }
View Full Code Here

      whitelist.addTags(el.getTagName());
            if(!el.getAttributes().isEmpty()) {
                whitelist.addAttributes(el.getTagName(), el.getAttributes().toArray(new String[el.getAttributes().size()]));
            }
    }
    cleaner = new Cleaner(whitelist);

    if(options.getTables().isLeftAsHtml()) {
      // we need to allow the table nodes to be ignored
      // since they are automatically ignored recursively, this is the only node we worry about.
      options.getIgnoredHtmlElements().add(IgnoredHtmlElement.create("table"));
View Full Code Here

     @see Cleaner#clean(Document)
     */
    public static String clean(String bodyHtml, String baseUri, Whitelist whitelist) {
        Document dirty = parseBodyFragment(bodyHtml, baseUri);
        Cleaner cleaner = new Cleaner(whitelist);
        Document clean = cleaner.clean(dirty);
        return clean.body().html();
    }
View Full Code Here

     * @return safe HTML (body fragment)
     * @see Cleaner#clean(Document)
     */
    public static String clean(String bodyHtml, String baseUri, Whitelist whitelist, Document.OutputSettings outputSettings) {
        Document dirty = parseBodyFragment(bodyHtml, baseUri);
        Cleaner cleaner = new Cleaner(whitelist);
        Document clean = cleaner.clean(dirty);
        clean.outputSettings(outputSettings);
        return clean.body().html();
    }
View Full Code Here

     @return true if no tags or attributes were removed; false otherwise
     @see #clean(String, org.jsoup.safety.Whitelist)
     */
    public static boolean isValid(String bodyHtml, Whitelist whitelist) {
        Document dirty = parseBodyFragment(bodyHtml, "");
        Cleaner cleaner = new Cleaner(whitelist);
        return cleaner.isValid(dirty);
    }
View Full Code Here

  public static String handleContent(String content, String baseUri, boolean keepTextOnly) {
    if (StringUtils.isNotBlank(content)) {
      baseUri = StringUtils.trimToEmpty(baseUri);

      Document dirty = Jsoup.parseBodyFragment(content, baseUri);
      Cleaner cleaner = new Cleaner(WHITELIST);
      Document clean = cleaner.clean(dirty);

      for (Element e : clean.select("iframe[style]")) {
        String style = e.attr("style");
        String escaped = escapeIFrameCss(style);
        e.attr("style", escaped);
View Full Code Here

  public boolean isValid(CharSequence value, ConstraintValidatorContext context) {
    if ( value == null ) {
      return true;
    }

    return new Cleaner( whitelist ).isValid( getFragmentAsDocument( value ) );
  }
View Full Code Here

  public boolean isValid(CharSequence value, ConstraintValidatorContext context) {
    if ( value == null ) {
      return true;
    }

    return new Cleaner( whitelist ).isValid( getFragmentAsDocument( value ) );
  }
View Full Code Here

TOP

Related Classes of org.jsoup.safety.Cleaner$CleaningVisitor

Copyright © 2018 www.massapicom. 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.