Skip to content

Commit

Permalink
Secure SAXParser (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosthe19916 authored Dec 17, 2022
1 parent 200d673 commit 615a463
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ public static XmlContent getSunatDocument(InputStream is) throws ParserConfigura
XmlHandler handler = new XmlHandler();

SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setNamespaceAware(true);

SAXParser parser = factory.newSAXParser();
parser.getXMLReader().setFeature("http://xml.org/sax/features/external-general-entities", false);
parser.parse(is, handler);

return handler.getModel();
Expand Down

0 comments on commit 615a463

Please sign in to comment.