SafeContentHandler extends ContentHandlerDecorator { @Override public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { filter(ch, start, length, ignorableWhitespaceOutput); } SafeContentHandler(ContentHandler handler); @Override void startElement(
            String uri, String localName, String name, Attributes atts); @Override void endElement(String uri, String localName, String name); @Override void endDocument(); @Override void characters(char[] ch, int start, int length); @Override void ignorableWhitespace(char[] ch, int start, int length);  }
@Test public void testNormalWhitespace() throws SAXException { safe.ignorableWhitespace("abc".toCharArray(), 0, 3); assertEquals("abc", output.toString()); }
@Test public void testInvalidWhitespace() throws SAXException { safe.ignorableWhitespace("ab\u0000".toCharArray(), 0, 3); safe.ignorableWhitespace("a\u0001c".toCharArray(), 0, 3); safe.ignorableWhitespace("\u0002bc".toCharArray(), 0, 3); assertEquals("ab\ufffda\ufffdc\ufffdbc", output.toString()); }
@Test public void testInvalidSurrogates() throws SAXException { safe.ignorableWhitespace("\udb00\ubfff".toCharArray(), 0, 2); assertEquals("\ufffd\ubfff", output.toString()); }