You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2025/09/26 12:11:56 UTC

(lucene) branch main updated: Remove unused method which does unsafe XML parsing (#15234)

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

uschindler pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new 79cb40f6ada Remove unused method which does unsafe XML parsing (#15234)
79cb40f6ada is described below

commit 79cb40f6adae50074e6fe2ff5235aaf43f5dce7f
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Fri Sep 26 14:11:51 2025 +0200

    Remove unused method which does unsafe XML parsing (#15234)
---
 lucene/CHANGES.txt                                 |  3 ++
 .../apache/lucene/queryparser/xml/DOMUtils.java    | 41 ++++------------------
 2 files changed, 10 insertions(+), 34 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index a1f352a5484..2e17ef96051 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -131,6 +131,9 @@ API Changes
   IDs at once, in particular by taking advantage of the new
   NumericDocValues#longValues API. (Adrien Grand)
 
+* GITHUB#15234: Remove unused method which does unsafe XML parsing.
+  (Uwe Schindler, Isaac David)
+
 New Features
 ---------------------
 * GITHUB#14565: Add ParentsChildrenBlockJoinQuery that supports parent and child filter in the same query
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/DOMUtils.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/DOMUtils.java
index 2ce342e17d8..cf5117bc8d9 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/DOMUtils.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/DOMUtils.java
@@ -16,17 +16,18 @@
  */
 package org.apache.lucene.queryparser.xml;
 
-import java.io.Reader;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
 
-/** Helper methods for parsing XML */
+/**
+ * Helper methods for parsing XML.
+ *
+ * @lucene.internal
+ */
 public class DOMUtils {
 
+  private DOMUtils() {}
+
   public static Element getChildByTagOrFail(Element e, String name) throws ParserException {
     Element kid = getChildByTagName(e, name);
     if (null == kid) {
@@ -174,32 +175,4 @@ public class DOMUtils {
       }
     }
   }
-
-  /**
-   * Helper method to parse an XML file into a DOM tree, given a reader.
-   *
-   * @param is reader of the XML file to be parsed
-   * @return an org.w3c.dom.Document object
-   */
-  public static Document loadXML(Reader is) {
-    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-    DocumentBuilder db = null;
-
-    try {
-      db = dbf.newDocumentBuilder();
-    } catch (Exception se) {
-      throw new RuntimeException("Parser configuration error", se);
-    }
-
-    // Step 3: parse the input file
-    org.w3c.dom.Document doc = null;
-    try {
-      doc = db.parse(new InputSource(is));
-      // doc = db.parse(is);
-    } catch (Exception se) {
-      throw new RuntimeException("Error parsing file:" + se, se);
-    }
-
-    return doc;
-  }
 }