@Test public void testSanitizeSpaces() { HtmlSanitizerService service = Framework.getService(HtmlSanitizerService.class); assertEquals("<strong>strong</strong>\n<em>content</em>", service.sanitizeString( "<strong>strong</strong><em>content</em>", null)); assertEquals("<p><strong>strong</strong><em>content</em></p>", service.sanitizeString( "<p><strong>strong</strong><em>content</em></p>", null)); }
@Override public String sanitizeString(String string, String info) { if (policy == null) { log.error("Cannot sanitize, no policy registered"); return string; } try { CleanResults cr = new AntiSamy().scan(string, policy); for (Object err : cr.getErrorMessages()) { log.debug(String.format("Sanitizing %s: %s", info == null ? "" : info, err)); } return cr.getCleanHTML(); } catch (Exception e) { log.error(String.format("Cannot sanitize %s: %s", info == null ? "" : info, e)); return string; } }
HtmlSanitizerServiceImpl extends DefaultComponent implements
        HtmlSanitizerService { @Override public String sanitizeString(String string, String info) { if (policy == null) { log.error("Cannot sanitize, no policy registered"); return string; } try { CleanResults cr = new AntiSamy().scan(string, policy); for (Object err : cr.getErrorMessages()) { log.debug(String.format("Sanitizing %s: %s", info == null ? "" : info, err)); } return cr.getCleanHTML(); } catch (Exception e) { log.error(String.format("Cannot sanitize %s: %s", info == null ? "" : info, e)); return string; } } }
HtmlSanitizerServiceImpl extends DefaultComponent implements
        HtmlSanitizerService { @Override public String sanitizeString(String string, String info) { if (policy == null) { log.error("Cannot sanitize, no policy registered"); return string; } try { CleanResults cr = new AntiSamy().scan(string, policy); for (Object err : cr.getErrorMessages()) { log.debug(String.format("Sanitizing %s: %s", info == null ? "" : info, err)); } return cr.getCleanHTML(); } catch (Exception e) { log.error(String.format("Cannot sanitize %s: %s", info == null ? "" : info, e)); return string; } }  }
HtmlSanitizerServiceImpl extends DefaultComponent implements
        HtmlSanitizerService { @Override public String sanitizeString(String string, String info) { if (policy == null) { log.error("Cannot sanitize, no policy registered"); return string; } try { CleanResults cr = new AntiSamy().scan(string, policy); for (Object err : cr.getErrorMessages()) { log.debug(String.format("Sanitizing %s: %s", info == null ? "" : info, err)); } return cr.getCleanHTML(); } catch (Exception e) { log.error(String.format("Cannot sanitize %s: %s", info == null ? "" : info, e)); return string; } }  @Override void registerContribution(Object contribution,
            String extensionPoint, ComponentInstance contributor); @Override void unregisterContribution(Object contribution,
            String extensionPoint, ComponentInstance contributor); @Override void sanitizeDocument(DocumentModel doc); @Override String sanitizeString(String string, String info); }
HtmlSanitizerServiceImpl extends DefaultComponent implements
        HtmlSanitizerService { @Override public String sanitizeString(String string, String info) { if (policy == null) { log.error("Cannot sanitize, no policy registered"); return string; } try { CleanResults cr = new AntiSamy().scan(string, policy); for (Object err : cr.getErrorMessages()) { log.debug(String.format("Sanitizing %s: %s", info == null ? "" : info, err)); } return cr.getCleanHTML(); } catch (Exception e) { log.error(String.format("Cannot sanitize %s: %s", info == null ? "" : info, e)); return string; } }  @Override void registerContribution(Object contribution,
            String extensionPoint, ComponentInstance contributor); @Override void unregisterContribution(Object contribution,
            String extensionPoint, ComponentInstance contributor); @Override void sanitizeDocument(DocumentModel doc); @Override String sanitizeString(String string, String info); static final String ANTISAMY_XP; static final String SANITIZER_XP; public LinkedList<HtmlSanitizerAntiSamyDescriptor> allPolicies; public Policy policy; public List<HtmlSanitizerDescriptor> allSanitizers; public List<HtmlSanitizerDescriptor> sanitizers; }