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

andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git


The following commit(s) were added to refs/heads/main by this push:
     new d410440f6c GH-3310: AlgResolveIRI.remove_dot_segements: protect 
against zero array split
d410440f6c is described below

commit d410440f6c630c4c3ef51afa159c7d381dcd63a3
Author: Andy Seaborne <[email protected]>
AuthorDate: Mon Jul 14 10:37:55 2025 +0100

    GH-3310: AlgResolveIRI.remove_dot_segements: protect against zero array 
split
---
 .../src/main/java/org/apache/jena/rfc3986/AlgResolveIRI.java       | 7 ++++++-
 jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseURN.java   | 1 -
 .../src/test/java/org/apache/jena/rfc3986/TestNormalize.java       | 5 +++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git 
a/jena-iri3986/src/main/java/org/apache/jena/rfc3986/AlgResolveIRI.java 
b/jena-iri3986/src/main/java/org/apache/jena/rfc3986/AlgResolveIRI.java
index 22c0c0d54b..d560f885cc 100644
--- a/jena-iri3986/src/main/java/org/apache/jena/rfc3986/AlgResolveIRI.java
+++ b/jena-iri3986/src/main/java/org/apache/jena/rfc3986/AlgResolveIRI.java
@@ -189,9 +189,14 @@ public class AlgResolveIRI {
             return "";
         if ( path.equals("/") )
             return "/";
+        // String.split -- "Trailing empty strings are not included in the 
results."
         String[] segments = path.split("/");
-
         int N = segments.length;
+        if ( N == 0 ) {
+            // If the path is two or more "/" and nothing else, then no 
segments.
+            return path;
+        }
+
         boolean initialSlash = segments[0].isEmpty();
         boolean trailingSlash = false;
         // Trailing slash if it isn't the initial "/" and it ends in "/" or 
"/." or "/.."
diff --git a/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseURN.java 
b/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseURN.java
index 744f7da578..31a6a8c58c 100644
--- a/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseURN.java
+++ b/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseURN.java
@@ -215,7 +215,6 @@ public class ParseURN {
             handler.accept(Issue.urn_bad_nid, "No namespace id");
             return -1;
         }
-
         if ( ch == ':' ) {
             handler.accept(Issue.urn_bad_nid, "Missing namespace id");
             return -1;
diff --git 
a/jena-iri3986/src/test/java/org/apache/jena/rfc3986/TestNormalize.java 
b/jena-iri3986/src/test/java/org/apache/jena/rfc3986/TestNormalize.java
index 130671d8ab..c0cd569f11 100644
--- a/jena-iri3986/src/test/java/org/apache/jena/rfc3986/TestNormalize.java
+++ b/jena-iri3986/src/test/java/org/apache/jena/rfc3986/TestNormalize.java
@@ -40,6 +40,11 @@ public class TestNormalize {
     @Test public void normalize_14() { 
testNormalize("http://host/foobar?q=s%74";, "http://host/foobar?q=st";); }
     @Test public void normalize_15() { testNormalize("http://host/foobar#%7E";, 
"http://host/foobar#~";); }
 
+    @Test public void normalize_21() { testNormalize("http://host/foobar///";, 
"http://host/foobar/";); }
+    @Test public void normalize_22() { testNormalize("http://host//";, 
"http://host//";); }
+    @Test public void normalize_23() { testNormalize("http://host//..";, 
"http://host/";); }
+    @Test public void normalize_24() { testNormalize("http://host/abc//..";, 
"http://host/abc/";); }
+
     private void testNormalize(String input, String expected) {
         IRI3986 iri = RFC3986.create(input);
         IRI3986 iri2 = iri.normalize();

Reply via email to