This is an automated email from the ASF dual-hosted git repository.
janhoy pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new bd2c95a5798 SOLR-18420: Improve ZookeeperRead path normalization
bd2c95a5798 is described below
commit bd2c95a5798a8089394f630020d0e5d79a3196d4
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 bf0db85fcdb..7157a5bdbfe 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);
}
@@ -120,13 +124,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 */