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

janhoy pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_10x by this push:
     new 883e98b01db SOLR-18420: Improve ZookeeperRead path normalization
883e98b01db is described below

commit 883e98b01db27eba3da93e2e88641f45fe69996e
Author: Jan Høydahl <[email protected]>
AuthorDate: Fri Sep 4 14:04:15 2026 +0200

    SOLR-18420: Improve ZookeeperRead path normalization
    
    (cherry picked from commit c1d0b6737bab3bfadb8153866e06c134ad924c85)
---
 .../java/org/apache/solr/handler/admin/ZookeeperRead.java | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperRead.java 
b/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperRead.java
index bf50e28c43c..9150cf41b9d 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperRead.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperRead.java
@@ -17,6 +17,7 @@
 
 package org.apache.solr.handler.admin;
 
+import static 
org.apache.solr.common.cloud.ZkStateReader.SOLR_SECURITY_CONF_PATH;
 import static 
org.apache.solr.security.PermissionNameProvider.Name.SECURITY_READ_PERM;
 import static 
org.apache.solr.security.PermissionNameProvider.Name.ZK_READ_PERM;
 
@@ -68,6 +69,9 @@ public class ZookeeperRead extends AdminAPIBase implements 
ZooKeeperReadApis {
   @PermissionName(ZK_READ_PERM)
   public StreamingOutput readNode(String zkPath) {
     zkPath = sanitizeZkPath(zkPath);
+    if (SOLR_SECURITY_CONF_PATH.equals(zkPath)) {
+      throw new SolrException(SolrException.ErrorCode.NOT_FOUND, "No such 
node: " + zkPath);
+    }
     return readNodeAndAddToResponse(zkPath);
   }
 
@@ -118,13 +122,14 @@ public class ZookeeperRead extends AdminAPIBase 
implements ZooKeeperReadApis {
   }
 
   private String sanitizeZkPath(String zkPath) {
-    if (zkPath == null || zkPath.isEmpty()) {
+    if (zkPath == null) {
       return "/";
-    } else if (zkPath.length() > 1 && zkPath.endsWith("/")) {
-      return zkPath.substring(0, zkPath.length() - 1);
     }
-
-    return zkPath;
+    zkPath = zkPath.trim();
+    while (zkPath.length() > 1 && zkPath.endsWith("/")) {
+      zkPath = zkPath.substring(0, zkPath.length() - 1);
+    }
+    return zkPath.isEmpty() ? "/" : zkPath;
   }
 
   /** Simple mime type guessing based on first character of the response */

Reply via email to