Skip to content

Commit

Permalink
Revert "Merge pull request #56 from ppkarwasz/master"
Browse files Browse the repository at this point in the history
This reverts commit 9a029af, reversing
changes made to fb382fd.
  • Loading branch information
ceki committed Nov 21, 2022
1 parent 9a029af commit 05f811c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/main/java/org/apache/log4j/xml/DOMConfigurator.java
Expand Up @@ -788,16 +788,6 @@ public String toString() {
doConfigure(action, repository);
}

private final void setFeature(final DocumentBuilderFactory dbf, final String feature, final boolean value) {
try {
dbf.setFeature(feature, value);
} catch (Exception e) {
LogLog.warn("Failed to set DocumentBuilderFactory feature " + feature + ".", e);
} catch (AbstractMethodError e) {
LogLog.warn("Failed to set DocumentBuilderFactory feature " + feature + ". Missing DocumentBuilderFactory.setFeature() method?", e);
}
}

private final void doConfigure(final ParseAction action, final LoggerRepository repository)
throws FactoryConfigurationError {
DocumentBuilderFactory dbf = null;
Expand All @@ -816,8 +806,8 @@ private final void doConfigure(final ParseAction action, final LoggerRepository
try {
dbf.setValidating(true);
// prevent XXE attacks
setFeature(dbf, "http://xml.org/sax/features/external-general-entities", false);
setFeature(dbf, "http://xml.org/sax/features/external-parameter-entities", false);
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);

DocumentBuilder docBuilder = dbf.newDocumentBuilder();

Expand All @@ -831,6 +821,9 @@ private final void doConfigure(final ParseAction action, final LoggerRepository
Thread.currentThread().interrupt();
}
LogLog.error("Could not parse " + action.toString() + ".", e);
} catch (AbstractMethodError e) {
LogLog.error("Failed to parse XML file. Missing DocumentBuilderFactory.setFeature() method?", e);
throw e;
}
}

Expand Down

0 comments on commit 05f811c

Please sign in to comment.