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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new 5c66eaa681 Improved: Refactor readHtmlDocument in UelFunctions to 
obtain an instance of org.w3c.dom.Document using the standard 
javax.xml.parsers.* APIs instead of org.cyberneko.html.
5c66eaa681 is described below

commit 5c66eaa681ad0ac7fec5410b764463e651cac300
Author: Jacopo Cappellato <[email protected]>
AuthorDate: Wed Nov 19 14:59:05 2025 +0100

    Improved: Refactor readHtmlDocument in UelFunctions to obtain an instance 
of org.w3c.dom.Document using the standard javax.xml.parsers.* APIs instead of 
org.cyberneko.html.
    
    Removing the Cyberneko dependency allows us to drop the Maven repository
    https://repository.ow2.org/nexus/content/repositories/public/, which is
    offline at the time of this commit (due to a license issue) and was
    causing OFBiz builds to fail. This repository has also had issues in the
    recent past, as reported in
    https://issues.apache.org/jira/browse/OFBIZ-13206.
---
 build.gradle                                               |  4 ----
 dependencies.gradle                                        |  1 -
 .../org/apache/ofbiz/base/util/string/UelFunctions.java    | 14 ++++++++------
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/build.gradle b/build.gradle
index 5c383262f7..c7d141bf2b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -205,10 +205,6 @@ allprojects {
         maven {
             url 'https://clojars.org/repo'
         }
-        maven {
-            // org.cyberneko.html.parsers (used by UELFunctions, was in esapi 
before 2.3)
-            url "https://repository.ow2.org/nexus/content/repositories/public/";
-        }
         maven {
             url 
"https://artifacts.alfresco.com/nexus/content/repositories/public/";
         }
diff --git a/dependencies.gradle b/dependencies.gradle
index bcfed3b957..d1dc36dd10 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -70,7 +70,6 @@ dependencies {
     implementation 'org.apache.groovy:groovy-all:5.0.0-alpha-11'
     implementation 'org.freemarker:freemarker:2.3.34' // Remember to change 
the version number in FreeMarkerWorker class when upgrading. See OFBIZ-10019 if 
>= 2.4
     implementation 'org.owasp.esapi:esapi:2.6.0.0'
-    implementation 'org.cyberneko:html:1.9.8'
     implementation 'org.springframework:spring-test:6.1.16'
     implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
     implementation 'oro:oro:2.0.8'
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 3d8f924a2d..84ec581fd1 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
@@ -36,6 +36,9 @@ import java.util.Map;
 import java.util.TimeZone;
 
 import jakarta.el.FunctionMapper;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
@@ -49,7 +52,6 @@ import org.apache.ofbiz.base.util.UtilDateTime;
 import org.apache.ofbiz.base.util.UtilProperties;
 import org.apache.ofbiz.base.util.UtilXml;
 import org.apache.ofbiz.widget.renderer.ScreenRenderer;
-import org.cyberneko.html.parsers.DOMParser;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
@@ -365,14 +367,14 @@ public class UelFunctions {
         try {
             URL url = FlexibleLocation.resolveLocation(str);
             if (url != null) {
-                DOMParser parser = new DOMParser();
-                parser.setFeature("http://xml.org/sax/features/namespaces";, 
false);
-                parser.parse(url.toExternalForm());
-                document = parser.getDocument();
+                DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();
+                DocumentBuilder builder = factory.newDocumentBuilder();
+                document = builder.parse(url.openStream());
+                document.getDocumentElement().normalize();
             } else {
                 Debug.logError("Unable to locate HTML document " + str, 
MODULE);
             }
-        } catch (IOException | SAXException e) {
+        } catch (IOException | ParserConfigurationException | SAXException e) {
             Debug.logError(e, "Error while reading HTML document " + str, 
MODULE);
         }
         return document;

Reply via email to