Example usage for org.jsoup.safety Whitelist none

List of usage examples for org.jsoup.safety Whitelist none

Introduction

In this page you can find the example usage for org.jsoup.safety Whitelist none.

Prototype

public static Whitelist none() 

Source Link

Document

This whitelist allows only text nodes: all HTML will be stripped.

Usage

From source file:Main.java

public static String cleanHtml(String str) {
    Document.OutputSettings settings = new Document.OutputSettings();
    settings.escapeMode(Entities.EscapeMode.xhtml);
    return Jsoup.clean(str, "", Whitelist.none(), settings);
}

From source file:net.duckling.falcon.xss.JSONConfig.java

public static Whitelist parse(String filename) throws IOException, ParseException {
    String jsonString = FileUtils.readFileToString(new File(filename), "UTF-8");
    JSONParser parser = new JSONParser();
    Object obj = parser.parse(jsonString);
    if (obj instanceof JSONObject) {
        Whitelist whitelist = new Whitelist();
        JSONObject config = (JSONObject) obj;
        addTags(whitelist, config);/*w w  w .j  a v  a2  s  . com*/
        addProtocols(whitelist, config);
        return whitelist;
    }
    return Whitelist.none();
}

From source file:edu.harvard.iq.dataverse.util.MarkupChecker.java

/**
 * Strip all HTMl tags/*  w  w  w  . ja v  a  2 s. c om*/
 * 
 * http://jsoup.org/apidocs/org/jsoup/safety/Whitelist.html#none%28%29
 * 
 * @param unsafe
 * @return 
 */
public static String stripAllTags(String unsafe) {

    if (unsafe == null) {
        return null;
    }

    return Jsoup.clean(unsafe, Whitelist.none());

}

From source file:com.omnigon.aem.common.utils.StringUtils.java

/**
 *
 * @param src source string/*from www  .j a va  2 s  . com*/
 * @return string without any HTML tags inside
 */
public static String removeHtmlTags(String src) {
    return Jsoup.clean(src, Whitelist.none());
}

From source file:edu.cornell.mannlib.vitro.webapp.search.solr.CleanAllText.java

protected String clean(String in) {
    String stripped = null;//from  ww w  .ja v a 2s  .c  o m
    try {
        stripped = Jsoup.clean(in, Whitelist.none());
    } catch (Exception e) {
        log.debug("Could not strip HTML during indexing. ", e);
    }
    if (stripped == null)
        return in;
    else
        return in;
}

From source file:info.magnolia.vaadin.periscope.result.Result.java

public Result(String htmlText, final Runnable action) {
    this(htmlText, action, Jsoup.clean(htmlText, Whitelist.none()), null);
}

From source file:automation.Launcher.java

public static String br2nl(String html) {
    if (html == null) {
        return html;
    }//w w w .j a  v  a  2 s . c  om
    Document document = Jsoup.parse(html);
    document.outputSettings(new Document.OutputSettings().prettyPrint(false));//makes html() preserve linebreaks and spacing
    document.select("p").prepend("\\n\\n");
    document.select("div").prepend("\\n");
    //   System.out.println(document.html());
    document.select("br").append("\\n");
    //   System.out.println(document.html());

    String s = document.html().replaceAll("\\\\n", "\n");
    //   System.out.println(s);
    return Jsoup.clean(s, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false));
}

From source file:com.sap.dirigible.ide.bridge.ext.XSSRequestWrapper.java

private String stripXSS(String value) {
    if (value != null) {
        value = StringEscapeUtils.escapeHtml(value);
        value = StringEscapeUtils.escapeJavaScript(value);
        value = value.replaceAll("", ""); //$NON-NLS-1$ //$NON-NLS-2$
        value = Jsoup.clean(value, Whitelist.none());
    }//from ww w.j  ava  2s. c o  m
    return value;
}

From source file:com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizerTest.java

/**
 * Fails: unescapes &num, &chi, and &int to #, , and  respectively
 * Expected :http://www.foo.com?a=1&num_rooms=1&children=0&int=VA&b=2
 * Actual   :http://www.foo.com?a=1#_rooms=1ldren=0=VA&b=2
 *//*from  ww w  . j  av a2  s. c o m*/
@Test
@Ignore
public void testJsoupClean() throws Exception {
    String html = "<a href=\"" + URL + "\">" + URL + "</a>";
    assertEquals(URL, Jsoup.clean(html, Whitelist.none()));
}

From source file:org.appverse.web.framework.backend.api.helpers.json.JSONHtmlXssSerializer.java

public String stripXSS(String value) {
    if (value != null) {
        System.out.println("STRIP XSS -> [" + value + "]");
        // Use the ESAPI library to avoid encoded attacks.
        value = ESAPI.encoder().canonicalize(value);

        // Avoid null characters
        value = value.replaceAll("\0", "");

        // Clean out HTML
        value = Jsoup.clean(value, Whitelist.none());
        System.out.println("STRIPED XSS -> [" + value + "]");
    }//from w w  w  . ja v  a  2s  .  c  o m
    return value;
}