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 <[email protected]>
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",

Reply via email to