@Test public void testFilterHtmlUsingUnmatchedHtml() { String text = "XSS <a href=\"http: Assertions.assertEquals("XSS alert('XSS').", HtmlTextFilter.filter(text)); }
public static String filter(String text) { if ( text == null ) { return text; } Document document = Jsoup.parse(text); document.outputSettings(new Document.OutputSettings().prettyPrint(false)); document.select("br").append("\\n"); document.select("p").prepend("\\n\\n"); String s = document.html().replaceAll("\\\\n", "\n"); return Jsoup.clean(s, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)); }
HtmlTextFilter { public static String filter(String text) { if ( text == null ) { return text; } Document document = Jsoup.parse(text); document.outputSettings(new Document.OutputSettings().prettyPrint(false)); document.select("br").append("\\n"); document.select("p").prepend("\\n\\n"); String s = document.html().replaceAll("\\\\n", "\n"); return Jsoup.clean(s, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)); } }
HtmlTextFilter { public static String filter(String text) { if ( text == null ) { return text; } Document document = Jsoup.parse(text); document.outputSettings(new Document.OutputSettings().prettyPrint(false)); document.select("br").append("\\n"); document.select("p").prepend("\\n\\n"); String s = document.html().replaceAll("\\\\n", "\n"); return Jsoup.clean(s, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)); } private  HtmlTextFilter(); }
HtmlTextFilter { public static String filter(String text) { if ( text == null ) { return text; } Document document = Jsoup.parse(text); document.outputSettings(new Document.OutputSettings().prettyPrint(false)); document.select("br").append("\\n"); document.select("p").prepend("\\n\\n"); String s = document.html().replaceAll("\\\\n", "\n"); return Jsoup.clean(s, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)); } private  HtmlTextFilter(); static String filter(String text); }
HtmlTextFilter { public static String filter(String text) { if ( text == null ) { return text; } Document document = Jsoup.parse(text); document.outputSettings(new Document.OutputSettings().prettyPrint(false)); document.select("br").append("\\n"); document.select("p").prepend("\\n\\n"); String s = document.html().replaceAll("\\\\n", "\n"); return Jsoup.clean(s, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)); } private  HtmlTextFilter(); static String filter(String text);  }