Skip to content

Commit

Permalink
Increase limits for XML parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cushon committed Dec 19, 2024
1 parent d9f9c11 commit 81e63c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public final List<AbstractPatternRule> getRules(InputStream is, String filename,
Tools.setPasswordAuthenticator();
}
saxParser.getXMLReader().setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
saxParser.getXMLReader().setProperty("jdk.xml.maxGeneralEntitySizeLimit", 0);
saxParser.getXMLReader().setProperty("jdk.xml.totalEntitySizeLimit", 0);
saxParser.getXMLReader().setProperty("jdk.xml.entityExpansionLimit", 0);
saxParser.parse(is, handler);
return handler.getRules();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public final List<DisambiguationPatternRule> getRules(InputStream stream, Langua
DisambiguationRuleHandler handler = new DisambiguationRuleHandler(language, xmlPath);
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
saxParser.getXMLReader().setProperty("jdk.xml.maxGeneralEntitySizeLimit", 0);
saxParser.getXMLReader().setProperty("jdk.xml.totalEntitySizeLimit", 0);
saxParser.getXMLReader().setProperty("jdk.xml.entityExpansionLimit", 0);

if (JLanguageTool.isCustomPasswordAuthenticatorUsed()) {
Tools.setPasswordAuthenticator();
Expand Down

0 comments on commit 81e63c5

Please sign in to comment.