HtmlSanitizer { public static String sanitize(String unclean) { if (Strings.isNullOrEmpty(unclean)) { return unclean; } else { unclean = unclean.replace("\0", ""); return Jsoup.clean(unclean, html); } }  static String sanitize(String unclean); static String strip(String unclean);  }
@Test public void testInvalidMarkup() { assertEquals("<p>Local Aguaruna name: magkamak, katípas. <br> <br> Croat, Swart &amp; Yates 2005: 94</p>", sanitize("<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /> <meta content=\"Word.Document\" name=\"ProgId\" /> <meta content=\"Microsoft Word 11\" name=\"Generator\" /> <meta content=\"Microsoft Word 11\" name=\"Originator\" /> <link href=\"file: }
@Test public void testScratchpadReferenceMarkup() { assertEquals("<a href=\"http: sanitize("<div style=\" text-indent: -25px; padding-left: 25px;\"><span class=\"biblio-authors\"><a href=\"http: }
@Test public void testNeotropikeyGlossaryLinksArePreserved() { String input = "<strong>Leaves</strong><a href=\"http: String result = "<strong>Leaves</strong>\n<a href=\"http: assertEquals(result, sanitize(input)); }
@Test public void testControlCharacter() { assertEquals("William J. Baker", sanitize("William J. Baker" + ((char) 0))); assertEquals("<p>William J. Baker</p>", sanitize("<p>William J. Baker" + ((char) 0) + "</p>")); assertEquals("William J. Baker says hi!", sanitize("William J. Baker" + ((char) 0) + " says hi!")); }