You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/08/07 13:44:47 UTC

[tomcat] branch 10.0.x updated: Fix Tomcat start when XML parser does not support allow-java-encodings

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.0.x by this push:
     new bdc3888  Fix Tomcat start when XML parser does not support allow-java-encodings
bdc3888 is described below

commit bdc3888f05aca6d3fbeee306a688197e4b1d1de8
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sat Aug 7 15:42:48 2021 +0200

    Fix Tomcat start when XML parser does not support allow-java-encodings
---
 .../catalina/authenticator/jaspic/LocalStrings.properties  |  1 +
 .../jaspic/PersistentProviderRegistrations.java            | 14 +++++++++-----
 webapps/docs/changelog.xml                                 |  9 +++++++++
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties b/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties
index b86acb1..5d7e376 100644
--- a/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties
+++ b/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties
@@ -28,5 +28,6 @@ jaspicAuthenticator.authenticate=Authenticating request for [{0}] via JASPIC
 persistentProviderRegistrations.deleteFail=The temporary file [{0}] cannot be deleted
 persistentProviderRegistrations.existsDeleteFail=The temporary file [{0}] already exists and cannot be deleted
 persistentProviderRegistrations.moveFail=Failed to move [{0}] to [{1}]
+persistentProviderRegistrations.xmlFeatureEncoding=Exception configuring JASPIC to permit java encoding names in XML configuration files. Only IANA encoding names will be supported.
 
 simpleServerAuthConfig.noModules="No ServerAuthModules configured"
diff --git a/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java b/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
index 8ffe8ec..b533105 100644
--- a/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
+++ b/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
@@ -31,6 +31,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.digester.Digester;
@@ -43,6 +45,7 @@ import org.xml.sax.SAXException;
  */
 public final class PersistentProviderRegistrations {
 
+    private static final Log log = LogFactory.getLog(PersistentProviderRegistrations.class);
     private static final StringManager sm =
             StringManager.getManager(PersistentProviderRegistrations.class);
 
@@ -59,12 +62,13 @@ public final class PersistentProviderRegistrations {
 
             try {
                 digester.setFeature("http://apache.org/xml/features/allow-java-encodings", true);
-                digester.setValidating(true);
-                digester.setNamespaceAware(true);
-            } catch (Exception e) {
-                throw new SecurityException(e);
+            } catch (SAXException se) {
+                log.warn(sm.getString("persistentProviderRegistrations.xmlFeatureEncoding"), se);
             }
 
+            digester.setValidating(true);
+            digester.setNamespaceAware(true);
+
             // Create an object to hold the parse results and put it on the top
             // of the digester's stack
             Providers result = new Providers();
@@ -83,7 +87,7 @@ public final class PersistentProviderRegistrations {
             digester.parse(is);
 
             return result;
-        } catch (IOException | SAXException e) {
+        } catch (IOException | ParserConfigurationException | SAXException e) {
             throw new SecurityException(e);
         }
     }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 5d37475..b035c1a 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,15 @@
   issues do not "pop up" wrt. others).
 -->
 <section name="Tomcat 10.0.11 (markt)" rtext="in development">
+  <subsection name="Catalina">
+    <changelog>
+      <fix>
+        Enable Tomcat to start if an (old) XML parser is configured that does
+        not support <code>allow-java-encodings</code>. A warning will be logged
+        if such an XML parser is detected. (markt)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Coyote">
     <changelog>
       <fix>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org