Skip to content

Commit 266b72e

Browse files
Aleksei VoitylovRealCLanger
authored andcommitted
8370529: Enhance Path Factories Redux
Reviewed-by: abakhtin Backport-of: 17aa6f32a5e5bfcd30f79f1a101b6fdfeeecd6cc
1 parent deb63cd commit 266b72e

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/java.xml/share/classes/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package com.sun.org.apache.xpath.internal.jaxp;
2222

23+
import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
2324
import com.sun.org.apache.xml.internal.utils.WrappedRuntimeException;
2425
import com.sun.org.apache.xpath.internal.objects.XObject;
2526
import javax.xml.namespace.QName;
@@ -32,14 +33,15 @@
3233
import javax.xml.xpath.XPathFunctionResolver;
3334
import javax.xml.xpath.XPathVariableResolver;
3435
import jdk.xml.internal.JdkXmlFeatures;
36+
import jdk.xml.internal.XMLSecurityManager;
3537
import org.w3c.dom.Document;
3638
import org.xml.sax.InputSource;
3739

3840
/**
3941
* The XPathExpression interface encapsulates a (compiled) XPath expression.
4042
*
4143
* @author Ramesh Mandava
42-
* @LastModified: May 2022
44+
* @LastModified: Nov 2025
4345
*/
4446
public class XPathExpressionImpl extends XPathImplUtil implements XPathExpression {
4547

@@ -49,21 +51,26 @@ public class XPathExpressionImpl extends XPathImplUtil implements XPathExpressio
4951
* from the context.
5052
*/
5153
protected XPathExpressionImpl() {
52-
this(null, null, null, null, false, new JdkXmlFeatures(false));
54+
this(null, null, null, null, false, new JdkXmlFeatures(true),
55+
new XMLSecurityManager(true),
56+
new XMLSecurityPropertyManager());
5357
};
5458

5559
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
5660
JAXPPrefixResolver prefixResolver,
5761
XPathFunctionResolver functionResolver,
5862
XPathVariableResolver variableResolver) {
5963
this(xpath, prefixResolver, functionResolver, variableResolver,
60-
false, new JdkXmlFeatures(false));
64+
false, new JdkXmlFeatures(true),
65+
new XMLSecurityManager(true),
66+
new XMLSecurityPropertyManager());
6167
};
6268

6369
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
6470
JAXPPrefixResolver prefixResolver,XPathFunctionResolver functionResolver,
6571
XPathVariableResolver variableResolver, boolean featureSecureProcessing,
66-
JdkXmlFeatures featureManager) {
72+
JdkXmlFeatures featureManager, XMLSecurityManager xmlSecMgr,
73+
XMLSecurityPropertyManager xmlSecPropMgr) {
6774
this.xpath = xpath;
6875
this.prefixResolver = prefixResolver;
6976
this.functionResolver = functionResolver;
@@ -72,6 +79,8 @@ protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
7279
this.overrideDefaultParser = featureManager.getFeature(
7380
JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER);
7481
this.featureManager = featureManager;
82+
this.xmlSecMgr = xmlSecMgr;
83+
this.xmlSecPropMgr = xmlSecPropMgr;
7584
};
7685

7786
public void setXPath (com.sun.org.apache.xpath.internal.XPath xpath) {

src/java.xml/share/classes/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* New methods: evaluateExpression
5050
* Refactored to share code with XPathExpressionImpl.
5151
*
52-
* @LastModified: June 2025
52+
* @LastModified: Nov 2025
5353
*/
5454
public class XPathImpl extends XPathImplUtil implements javax.xml.xpath.XPath {
5555

@@ -171,7 +171,8 @@ public XPathExpression compile(String expression)
171171
// Can have errorListener
172172
XPathExpressionImpl ximpl = new XPathExpressionImpl (xpath,
173173
prefixResolver, functionResolver, variableResolver,
174-
featureSecureProcessing, featureManager);
174+
featureSecureProcessing, featureManager,
175+
xmlSecMgr, xmlSecPropMgr);
175176
return ximpl;
176177
} catch (TransformerException te) {
177178
throw new XPathExpressionException (te) ;

0 commit comments

Comments
 (0)