Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -41,7 +41,7 @@
* the expression executes, it calls ExtensionsTable#extFunction, and then
* converts the result to the appropriate XObject.
* @xsl.usage advanced
* @LastModified: May 2022
* @LastModified: Apr 2025
*/
public class FuncExtFunction extends Function
{
Expand Down Expand Up @@ -186,12 +186,6 @@ public FuncExtFunction(java.lang.String namespace,
*/
public XObject execute(XPathContext xctxt) throws TransformerException
{
if (xctxt.isSecureProcessing())
throw new javax.xml.transform.TransformerException(
XPATHMessages.createXPATHMessage(
XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
new Object[] {toString()}));

XObject result;
List<XObject> argVec = new ArrayList<>();
int nArgs = m_argVec.size();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -37,26 +37,16 @@
/**
*
* @author Ramesh Mandava
* @LastModified: Nov 2017
* @LastModified: Apr 2025
*/
public class JAXPExtensionsProvider implements ExtensionsProvider {

private final XPathFunctionResolver resolver;
private boolean extensionInvocationDisabled = false;

public JAXPExtensionsProvider(XPathFunctionResolver resolver) {
this.resolver = resolver;
this.extensionInvocationDisabled = false;
}

public JAXPExtensionsProvider(XPathFunctionResolver resolver,
boolean featureSecureProcessing, JdkXmlFeatures featureManager ) {
this.resolver = resolver;
if (featureSecureProcessing &&
!featureManager.getFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION)) {
this.extensionInvocationDisabled = true;
}
}

/**
* Is the extension function available?
Expand Down Expand Up @@ -111,16 +101,6 @@ public Object extFunction(String ns, String funcName, List<XObject> argVec,
//Find the XPathFunction corresponding to namespace and funcName
javax.xml.namespace.QName myQName = new QName( ns, funcName );

// JAXP 1.3 spec says When XMLConstants.FEATURE_SECURE_PROCESSING
// feature is set then invocation of extension functions need to
// throw XPathFunctionException
if ( extensionInvocationDisabled ) {
String fmsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
new Object[] { myQName.toString() } );
throw new XPathFunctionException ( fmsg );
}

// Assuming user is passing all the needed parameters ( including
// default values )
int arity = argVec.size();
Expand Down Expand Up @@ -167,16 +147,6 @@ public Object extFunction(FuncExtFunction extFunction, List<XObject> argVec)
javax.xml.namespace.QName myQName =
new javax.xml.namespace.QName( namespace, functionName );

// JAXP 1.3 spec says When XMLConstants.FEATURE_SECURE_PROCESSING
// feature is set then invocation of extension functions need to
// throw XPathFunctionException
if ( extensionInvocationDisabled ) {
String fmsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
new Object[] { myQName.toString() } );
throw new XPathFunctionException ( fmsg );
}

XPathFunction xpathFunction =
resolver.resolveFunction( myQName, arity );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -54,7 +54,7 @@
* This class contains several utility methods used by XPathImpl and
* XPathExpressionImpl
*
* @LastModified: Jan 2022
* @LastModified: Apr 2025
*/
class XPathImplUtil {
XPathFunctionResolver functionResolver;
Expand Down Expand Up @@ -85,8 +85,7 @@ XObject eval(Object contextItem, com.sun.org.apache.xpath.internal.XPath xpath)
new Object[] {}));
}
if (functionResolver != null) {
JAXPExtensionsProvider jep = new JAXPExtensionsProvider(
functionResolver, featureSecureProcessing, featureManager);
JAXPExtensionsProvider jep = new JAXPExtensionsProvider(functionResolver);
xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext(jep);
} else {
xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -31,7 +31,7 @@
* Also you need to update the count of messages(MAX_CODE)or
* the count of warnings(MAX_WARNING) [ Information purpose only]
* @xsl.usage advanced
* @LastModified: Nov 2024
* @LastModified: Apr 2025
*/
public class XPATHErrorResources extends ListResourceBundle
{
Expand Down Expand Up @@ -305,7 +305,6 @@ public class XPATHErrorResources extends ListResourceBundle
public static final String ER_XPATH_ERROR = "ER_XPATH_ERROR";

//BEGIN: Keys needed for exception messages of JAXP 1.3 XPath API implementation
public static final String ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED = "ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED";
public static final String ER_RESOLVE_VARIABLE_RETURNS_NULL = "ER_RESOLVE_VARIABLE_RETURNS_NULL";
public static final String ER_NO_XPATH_VARIABLE_RESOLVER = "ER_NO_XPATH_VARIABLE_RESOLVER";
public static final String ER_NO_XPATH_FUNCTION_PROVIDER = "ER_NO_XPATH_FUNCTION_PROVIDER";
Expand Down Expand Up @@ -766,11 +765,6 @@ public class XPATHErrorResources extends ListResourceBundle

//BEGIN: Definitions of error keys used in exception messages of JAXP 1.3 XPath API implementation

/** Field ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED */

{ ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
"Extension function: ''{0}'' can not be invoked when the XMLConstants.FEATURE_SECURE_PROCESSING feature is set to true."},

/** Field ER_RESOLVE_VARIABLE_RETURNS_NULL */

{ ER_RESOLVE_VARIABLE_RETURNS_NULL,
Expand Down
8 changes: 4 additions & 4 deletions src/java.xml/share/classes/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -868,19 +868,19 @@
* </tr>
* <tr>
* <td id="ExtFunc">{@systemProperty jdk.xml.enableExtensionFunctions}</td>
* <td>Determines if XSLT and XPath extension functions are to be allowed.
* <td>Determines whether extension functions in the Transform API are to be allowed.
* The extension functions in the XPath API are not affected by this property.
* </td>
* <td style="text-align:center" rowspan="5">yes</td>
* <td style="text-align:center" rowspan="3">Boolean</td>
* <td>
* true or false. True indicates that extension functions are allowed; False otherwise.
* </td>
* <td style="text-align:center">true</td>
* <td style="text-align:center">false</td>
* <td style="text-align:center">false</td>
* <td style="text-align:center">Yes</td>
* <td style="text-align:center">
* <a href="#Transform">Transform</a><br>
* <a href="#XPATH">XPath</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additional confirming text in the CSR is not present above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Roger. Updated the description for the jdk.xml.enableExtensionFunctions property and fixed the default value (missing from the JDK-8343001 patch).

* </td>
* <td style="text-align:center"><a href="#Processor">Method 2</a></td>
* <td style="text-align:center">8</td>
Expand Down
195 changes: 0 additions & 195 deletions test/jaxp/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java

This file was deleted.

This file was deleted.

Loading