summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-10-08 16:15:14 +0000
committerPJ Fanning <fanningpj@apache.org>2021-10-08 16:15:14 +0000
commit47118082ffbe065bffca3717f4d53e348c66e8b1 (patch)
treec4962770437701495ecac8768428495ff3b24095
parent2631c9a20ec0e18e74e113bcd080ac864438fe32 (diff)
downloadpoi-47118082ffbe065bffca3717f4d53e348c66e8b1.tar.gz
poi-47118082ffbe065bffca3717f4d53e348c66e8b1.zip
[bug-65326] accessExternalSchema is usually not accepted on TransformerFactory
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894032 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi/src/main/java/org/apache/poi/util/XMLHelper.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/poi/src/main/java/org/apache/poi/util/XMLHelper.java b/poi/src/main/java/org/apache/poi/util/XMLHelper.java
index 87a481b04c..8e7bae2898 100644
--- a/poi/src/main/java/org/apache/poi/util/XMLHelper.java
+++ b/poi/src/main/java/org/apache/poi/util/XMLHelper.java
@@ -223,7 +223,7 @@ public final class XMLHelper {
trySet(factory::setFeature, FEATURE_SECURE_PROCESSING, true);
trySet(factory::setAttribute, ACCESS_EXTERNAL_DTD, "");
trySet(factory::setAttribute, ACCESS_EXTERNAL_STYLESHEET, "");
- trySet(factory::setAttribute, ACCESS_EXTERNAL_SCHEMA, "");
+ quietSet(factory::setAttribute, ACCESS_EXTERNAL_SCHEMA, "");
return factory;
}
@@ -292,6 +292,16 @@ public final class XMLHelper {
return false;
}
+ private static boolean quietSet(SecurityProperty property, String name, Object value) {
+ try {
+ property.accept(name, value);
+ return true;
+ } catch (Exception|Error e) {
+ // ok to ignore
+ }
+ return false;
+ }
+
private static void logThrowable(Throwable t, String message, String name) {
if (System.currentTimeMillis() > lastLog + TimeUnit.MINUTES.toMillis(5)) {
LOG.atWarn().withThrowable(t).log("{} [log suppressed for 5 minutes]{}", message, name);