@Test(expected = SAXParseException.class) public void createXmlParser() throws SAXException, IOException { XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setContentHandler(new XMLReaderAdapter()); try { reader.parse(new InputSource(getXXEFileInjectionDocument())); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } reader = XmlUtils.createXmlReader(); reader.setContentHandler(new XMLReaderAdapter()); reader.parse(new InputSource(getXXEFileInjectionDocument())); }
public static XMLReader createXmlReader() throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setFeature(FEATURE_DISALLOW_DOCTYPE, true); reader.setFeature(FEATURE_EXTERNAL_GENERAL_ENTITIES, false); return reader; }
XmlUtils { public static XMLReader createXmlReader() throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setFeature(FEATURE_DISALLOW_DOCTYPE, true); reader.setFeature(FEATURE_EXTERNAL_GENERAL_ENTITIES, false); return reader; } }
XmlUtils { public static XMLReader createXmlReader() throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setFeature(FEATURE_DISALLOW_DOCTYPE, true); reader.setFeature(FEATURE_EXTERNAL_GENERAL_ENTITIES, false); return reader; } private  XmlUtils(); }
XmlUtils { public static XMLReader createXmlReader() throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setFeature(FEATURE_DISALLOW_DOCTYPE, true); reader.setFeature(FEATURE_EXTERNAL_GENERAL_ENTITIES, false); return reader; } private  XmlUtils(); static Document parseDocument(String xml); static Document parseDocument(InputStream documentXml); static Document parseDocument(InputStream documentXml, boolean namespaceAware); static String toXml(Node node); static Optional<Element> getFirstElementByTagName(Document doc, String tagName); static Element getElementXPathNS(Element parent, String xpathExpr, NamespaceContext nsCtx); static NodeList getElementsXPathNS(Element parent, String xpathExpr, NamespaceContext nsCtx); static Element getElementById(Document doc, String id); static byte[] canonicalize(String algorithmUri, Node node); static String prettyPrintXml(String xml); static String prettyPrintXml(Document document); static String prettyPrintXml(Document document, String charset, int indent); static DocumentBuilderFactory createDocumentBuilderFactory(); static XMLReader createXmlReader(); }
XmlUtils { public static XMLReader createXmlReader() throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setFeature(FEATURE_DISALLOW_DOCTYPE, true); reader.setFeature(FEATURE_EXTERNAL_GENERAL_ENTITIES, false); return reader; } private  XmlUtils(); static Document parseDocument(String xml); static Document parseDocument(InputStream documentXml); static Document parseDocument(InputStream documentXml, boolean namespaceAware); static String toXml(Node node); static Optional<Element> getFirstElementByTagName(Document doc, String tagName); static Element getElementXPathNS(Element parent, String xpathExpr, NamespaceContext nsCtx); static NodeList getElementsXPathNS(Element parent, String xpathExpr, NamespaceContext nsCtx); static Element getElementById(Document doc, String id); static byte[] canonicalize(String algorithmUri, Node node); static String prettyPrintXml(String xml); static String prettyPrintXml(Document document); static String prettyPrintXml(Document document, String charset, int indent); static DocumentBuilderFactory createDocumentBuilderFactory(); static XMLReader createXmlReader(); static final String FEATURE_EXTERNAL_GENERAL_ENTITIES; static final String FEATURE_DISALLOW_DOCTYPE; static final String FEATURE_EXTERNAL_PARAMETER_ENTITIES; }