You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2026/09/25 14:00:38 UTC

(ws-xmlschema) branch coheigea/fifo created (now fe6f5313)

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

coheigea pushed a change to branch coheigea/fifo
in repository https://gitbox.apache.org/repos/asf/ws-xmlschema.git


      at fe6f5313 Check a file: location relative to the working directory as a regular file

This branch includes the following new commits:

     new fe6f5313 Check a file: location relative to the working directory as a regular file

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(ws-xmlschema) 01/01: Check a file: location relative to the working directory as a regular file

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch coheigea/fifo
in repository https://gitbox.apache.org/repos/asf/ws-xmlschema.git

commit fe6f5313b9c92e463bd680f51d98c649a6fdc8af
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Fri Sep 25 15:00:20 2026 +0100

    Check a file: location relative to the working directory as a regular file
---
 .../schema/resolver/DefaultURIResolver.java        |  5 +++++
 .../test/java/tests/DefaultURIResolverTest.java    | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/xmlschema-core/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java b/xmlschema-core/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
index f9528777..d7c41f6d 100644
--- a/xmlschema-core/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
+++ b/xmlschema-core/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
@@ -622,6 +622,11 @@ public class DefaultURIResolver implements CollectionURIResolver {
         } catch (URISyntaxException e) {
             return null;
         }
+        if (parsed.isOpaque()) {
+            // "file:x", with no slash after the scheme, has no path as a URI, but the JDK opens it
+            // as x in the working directory, as it does a relative location with no base.
+            return relativeLocationFile(parsed.getRawSchemeSpecificPart());
+        }
         try {
             return new File(parsed);
         } catch (IllegalArgumentException e) {
diff --git a/xmlschema-core/src/test/java/tests/DefaultURIResolverTest.java b/xmlschema-core/src/test/java/tests/DefaultURIResolverTest.java
index 55eb7c4c..e3a2cd7b 100644
--- a/xmlschema-core/src/test/java/tests/DefaultURIResolverTest.java
+++ b/xmlschema-core/src/test/java/tests/DefaultURIResolverTest.java
@@ -476,6 +476,28 @@ public class DefaultURIResolverTest extends Assert {
         assertSchemeRefused("src?query", null, "not a regular file");
     }
 
+    /**
+     * "file:src", with no slash after the scheme, is an opaque URI with no path, but the JDK opens
+     * it as src in the working directory, so it must be checked as that file.
+     */
+    @Test
+    public void testAFileLocationRelativeToTheWorkingDirectoryIsChecked() {
+        assertTrue(new File("src").isDirectory());
+        assertSchemeRefused("file:src", null, "not a regular file");
+        assertSchemeRefused("file:./src", null, "not a regular file");
+        assertSchemeRefused("FILE:src", null, "not a regular file");
+        assertSchemeRefused("file:sr%63?query", null, "not a regular file");
+        assertSchemeRefused("jar:file:src!/x.xsd", null, "not a regular file");
+    }
+
+    @Test
+    public void testAFileLocationRelativeToTheWorkingDirectoryStillResolves() {
+        assertTrue(new File("pom.xml").isFile());
+        assertEquals("file:pom.xml",
+                     new DefaultURIResolver().resolveEntity("urn:x", "file:pom.xml", null)
+                         .getSystemId());
+    }
+
     @Test
     public void testARelativeRegularFileWithAFragmentStillResolves() {
         assertEquals("pom.xml#fragment",