This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/commons-xml.git
commit 7b8c9ed0aa130baa443260793a1f52cce0642c33 Author: Gary Gregory <[email protected]> AuthorDate: Fri Aug 28 13:24:55 2026 -0400 Rename HardeningXPath to SecureXPath. Local build OK. --- .../java/org/apache/commons/xml/HardeningXPathExpression.java | 10 +++++----- .../java/org/apache/commons/xml/HardeningXPathFactory.java | 6 +++--- .../commons/xml/{HardeningXPath.java => SecureXPath.java} | 4 ++-- .../java/org/apache/commons/xml/OverrideDefaultParserTest.java | 4 ++-- src/test/java/org/apache/commons/xml/ShadingFootprintTest.java | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/commons/xml/HardeningXPathExpression.java b/src/main/java/org/apache/commons/xml/HardeningXPathExpression.java index 851dcb4..37b7e97 100644 --- a/src/main/java/org/apache/commons/xml/HardeningXPathExpression.java +++ b/src/main/java/org/apache/commons/xml/HardeningXPathExpression.java @@ -27,9 +27,9 @@ import org.xml.sax.InputSource; /** - * {@link XPathExpression} wrapper that applies the same {@link InputSource} rewrite as {@link HardeningXPath} to the compiled evaluation entry points. + * {@link XPathExpression} wrapper that applies the same {@link InputSource} rewrite as {@link SecureXPath} to the compiled evaluation entry points. * <p> - * {@link HardeningXPath#compile(String)} returns one of these, so {@link #evaluate(InputSource)} and {@link #evaluate(InputSource, QName)} build the document + * {@link SecureXPath#compile(String)} returns one of these, so {@link #evaluate(InputSource)} and {@link #evaluate(InputSource, QName)} build the document * through a hardened, namespace-aware parser instead of the engine's own; the {@code evaluateExpression} default methods added by Java 9 route through these * overloads as well. * </p> @@ -39,7 +39,7 @@ final class HardeningXPathExpression implements XPathExpression { private final XPathExpression delegate; /** - * Snapshot of the factory's {@code jdk.xml.overrideDefaultParser} outcome, inherited from the {@link HardeningXPath} that compiled this expression. + * Snapshot of the factory's {@code jdk.xml.overrideDefaultParser} outcome, inherited from the {@link SecureXPath} that compiled this expression. */ private final boolean overrideDefaultParser; @@ -63,7 +63,7 @@ final class HardeningXPathExpression implements XPathExpression { */ @Override public String evaluate(final InputSource source) throws XPathExpressionException { - return delegate.evaluate(HardeningXPath.parse(source, overrideDefaultParser)); + return delegate.evaluate(SecureXPath.parse(source, overrideDefaultParser)); } /** @@ -74,7 +74,7 @@ public String evaluate(final InputSource source) throws XPathExpressionException */ @Override public Object evaluate(final InputSource source, final QName returnType) throws XPathExpressionException { - return delegate.evaluate(HardeningXPath.parse(source, overrideDefaultParser), returnType); + return delegate.evaluate(SecureXPath.parse(source, overrideDefaultParser), returnType); } @Override diff --git a/src/main/java/org/apache/commons/xml/HardeningXPathFactory.java b/src/main/java/org/apache/commons/xml/HardeningXPathFactory.java index 022e487..03416a1 100644 --- a/src/main/java/org/apache/commons/xml/HardeningXPathFactory.java +++ b/src/main/java/org/apache/commons/xml/HardeningXPathFactory.java @@ -187,11 +187,11 @@ private HardeningXPathFactory() { } /** - * {@link XPathFactory} wrapper that returns a {@link HardeningXPath} from {@link #newXPath()}. + * {@link XPathFactory} wrapper that returns a {@link SecureXPath} from {@link #newXPath()}. * * <p>Required because {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} on the factory governs only the XPath engine: the stock JDK and Apache Xalan * implement the {@link org.xml.sax.InputSource}-taking {@code evaluate} entry points by provisioning an internal document parser the feature does not reach. - * The wrapper performs that document build itself through a hardened parser instead; see {@link HardeningXPath}.</p> + * The wrapper performs that document build itself through a hardened parser instead; see {@link SecureXPath}.</p> * * @see org.apache.commons.xml */ @@ -222,7 +222,7 @@ public boolean isObjectModelSupported(final String objectModel) { @Override public XPath newXPath() { final XPath xpath = delegate.newXPath(); - return xpath == null ? null : new HardeningXPath(xpath, overrideDefaultParser()); + return xpath == null ? null : new SecureXPath(xpath, overrideDefaultParser()); } @Override diff --git a/src/main/java/org/apache/commons/xml/HardeningXPath.java b/src/main/java/org/apache/commons/xml/SecureXPath.java similarity index 98% rename from src/main/java/org/apache/commons/xml/HardeningXPath.java rename to src/main/java/org/apache/commons/xml/SecureXPath.java index dae10ce..98a6f8b 100644 --- a/src/main/java/org/apache/commons/xml/HardeningXPath.java +++ b/src/main/java/org/apache/commons/xml/SecureXPath.java @@ -49,7 +49,7 @@ * <p>The {@code evaluateExpression} default methods added to the interface by Java 9 route through the {@code evaluate} overloads overridden here, so they * carry the same rewrite on newer runtimes even though this class targets Java 8.</p> */ -final class HardeningXPath implements XPath { +final class SecureXPath implements XPath { /** * Parses the source through a hardened, namespace-aware {@link javax.xml.parsers.DocumentBuilder}, mirroring the namespace awareness of the parser the @@ -88,7 +88,7 @@ static Document parse(final InputSource source, final boolean overrideDefaultPar * @param overrideDefaultParser whether the {@link InputSource} document builds should use the pluggable parser lookup instead of the platform's built-in parser. * @throws NullPointerException if {@code delegate} is {@code null}. */ - HardeningXPath(final XPath delegate, final boolean overrideDefaultParser) { + SecureXPath(final XPath delegate, final boolean overrideDefaultParser) { this.delegate = Objects.requireNonNull(delegate, "delegate"); this.overrideDefaultParser = overrideDefaultParser; } diff --git a/src/test/java/org/apache/commons/xml/OverrideDefaultParserTest.java b/src/test/java/org/apache/commons/xml/OverrideDefaultParserTest.java index 0590509..39a1a02 100644 --- a/src/test/java/org/apache/commons/xml/OverrideDefaultParserTest.java +++ b/src/test/java/org/apache/commons/xml/OverrideDefaultParserTest.java @@ -123,8 +123,8 @@ void xPathFactoryReadsFeatureAtCreation() throws Exception { assumeFalse(AttackTestSupport.IS_ANDROID); final XPathFactory factory = HardeningXPathFactory.newDefaultInstance(); assertFalse(factory.getFeature(FEATURE)); - assertFalse(((HardeningXPath) factory.newXPath()).overrideDefaultParser); + assertFalse(((SecureXPath) factory.newXPath()).overrideDefaultParser); factory.setFeature(FEATURE, true); - assertTrue(((HardeningXPath) factory.newXPath()).overrideDefaultParser); + assertTrue(((SecureXPath) factory.newXPath()).overrideDefaultParser); } } diff --git a/src/test/java/org/apache/commons/xml/ShadingFootprintTest.java b/src/test/java/org/apache/commons/xml/ShadingFootprintTest.java index 9536ef4..540ca14 100644 --- a/src/test/java/org/apache/commons/xml/ShadingFootprintTest.java +++ b/src/test/java/org/apache/commons/xml/ShadingFootprintTest.java @@ -139,7 +139,7 @@ class ShadingFootprintTest { "SecureSAXParserFactory$HardeningExpatXMLReader", "SecureSAXParserFactory$Wrapper", "SecureXMLReader", - "HardeningXPath", + "SecureXPath", "HardeningXPathExpression", "HardeningXPathFactory", "HardeningXPathFactory$1",
