Created
May 4, 2020 12:19
-
-
Save ties/e2e29fa0834cd0354c6aec4acaba9376 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
/** | |
* Get an DocumentBuilder that is protected from entity injection. | |
* @return new DocumenBuilder | |
* @throws ParserConfigurationException when it feels like being peak java | |
*/ | |
public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { | |
final var df = DocumentBuilderFactory.newInstance(); | |
df.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); | |
df.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); | |
return df.newDocumentBuilder(); | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment