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

jacopoc pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 86c6f3a4f4c8d4fcfb5b5c44ec259743ba4dcd19
Author: Jacopo Cappellato <[email protected]>
AuthorDate: Mon Apr 27 18:14:31 2026 +0200

    Fixed: Wrap setAttribute(ACCESS_EXTERNAL_DTD, ...) calls to catch 
IllegalArgumentException thrown by older versions of Xalan/Saxon that predate 
JAXP 1.5
---
 .../main/java/org/apache/ofbiz/base/util/UtilXml.java    | 16 ++++++++++++----
 .../org/apache/ofbiz/base/util/string/UelFunctions.java  |  8 ++++++--
 .../apache/ofbiz/base/util/template/XslTransform.java    |  8 ++++++--
 .../java/org/apache/ofbiz/minilang/MiniLangUtil.java     |  8 ++++++--
 .../org/apache/ofbiz/webapp/view/ApacheFopWorker.java    |  8 ++++++--
 5 files changed, 36 insertions(+), 12 deletions(-)

diff --git 
a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java 
b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java
index c6e0440b01..6107279584 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java
@@ -228,8 +228,12 @@ public final class UtilXml {
         ByteArrayInputStream bis = new 
ByteArrayInputStream(sb.toString().getBytes());
         TransformerFactory transformerFactory = 
TransformerFactory.newInstance();
         transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, 
true);
-        transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
-        
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+        try {
+            transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, 
"");
+            
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+        } catch (IllegalArgumentException e) {
+            Debug.logWarning("TransformerFactory does not support 
ACCESS_EXTERNAL_* attributes: " + e.getMessage(), MODULE);
+        }
         return transformerFactory.newTransformer(new StreamSource(bis));
     }
 
@@ -1282,8 +1286,12 @@ public final class UtilXml {
         Transformer transformer;
         try {
             tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-            tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
-            tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+            try {
+                tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+                tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+            } catch (IllegalArgumentException e) {
+                Debug.logWarning("TransformerFactory does not support 
ACCESS_EXTERNAL_* attributes: " + e.getMessage(), MODULE);
+            }
             transformer = tf.newTransformer();
             transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
             transformer.setOutputProperty(OutputKeys.INDENT, "yes");
diff --git 
a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java
 
b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java
index e3f355bada..ee8de0fa5d 100644
--- 
a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java
+++ 
b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java
@@ -446,8 +446,12 @@ public class UelFunctions {
             ByteArrayInputStream bis = new 
ByteArrayInputStream(sb.toString().getBytes(StandardCharsets.UTF_8));
             TransformerFactory transformerFactory = 
TransformerFactory.newInstance();
             
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-            transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, 
"");
-            
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+            try {
+                
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+                
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+            } catch (IllegalArgumentException e) {
+                Debug.logWarning("TransformerFactory does not support 
ACCESS_EXTERNAL_* attributes: " + e.getMessage(), MODULE);
+            }
             try (ByteArrayOutputStream os = new ByteArrayOutputStream();) {
                 
UtilXml.transformDomDocument(transformerFactory.newTransformer(new 
StreamSource(bis)), node, os);
                 return os.toString();
diff --git 
a/framework/base/src/main/java/org/apache/ofbiz/base/util/template/XslTransform.java
 
b/framework/base/src/main/java/org/apache/ofbiz/base/util/template/XslTransform.java
index 53cba52653..ec56f0f368 100644
--- 
a/framework/base/src/main/java/org/apache/ofbiz/base/util/template/XslTransform.java
+++ 
b/framework/base/src/main/java/org/apache/ofbiz/base/util/template/XslTransform.java
@@ -50,8 +50,12 @@ public final class XslTransform {
         String result = null;
         TransformerFactory tfactory = TransformerFactory.newInstance();
         tfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-        tfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
-        tfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+        try {
+            tfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            tfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+        } catch (IllegalArgumentException e) {
+            Debug.logWarning("TransformerFactory does not support 
ACCESS_EXTERNAL_* attributes: " + e.getMessage(), MODULE);
+        }
         if (tfactory.getFeature(SAXSource.FEATURE)) {
             // setup for xml data file preprocessing to be able to xinclude
             SAXParserFactory pfactory = SAXParserFactory.newInstance();
diff --git 
a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangUtil.java 
b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangUtil.java
index 719802ff5a..70e695e4a7 100644
--- 
a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangUtil.java
+++ 
b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangUtil.java
@@ -284,8 +284,12 @@ public final class MiniLangUtil {
             styleSheetURL = 
FlexibleLocation.resolveLocation("component://minilang/config/MiniLang.xslt");
             TransformerFactory transformerFactory = 
TransformerFactory.newInstance();
             
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-            transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, 
"");
-            
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+            try {
+                
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+                
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+            } catch (IllegalArgumentException e) {
+                Debug.logWarning("TransformerFactory does not support 
ACCESS_EXTERNAL_* attributes: " + e.getMessage(), MODULE);
+            }
             try (InputStream styleSheetInStream = styleSheetURL.openStream()) {
                 transformer = transformerFactory.newTransformer(new 
StreamSource(styleSheetInStream));
             }
diff --git 
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/view/ApacheFopWorker.java
 
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/view/ApacheFopWorker.java
index 0bd0071f0b..a1ad59e0ab 100644
--- 
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/view/ApacheFopWorker.java
+++ 
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/view/ApacheFopWorker.java
@@ -167,8 +167,12 @@ public final class ApacheFopWorker {
         try {
             TransformerFactory factory = TransformerFactory.newInstance();
             factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-            factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
-            factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+            try {
+                factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+                factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, 
"");
+            } catch (IllegalArgumentException e) {
+                Debug.logWarning("TransformerFactory does not support 
ACCESS_EXTERNAL_* attributes: " + e.getMessage(), MODULE);
+            }
             Transformer transformer;
             if (stylesheet == null) {
                 transformer = factory.newTransformer();

Reply via email to