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

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


The following commit(s) were added to refs/heads/main by this push:
     new cabf786  SOLR-15804 Support leading slash for "file" parameter, to 
mean relative to config dir. Support text/javascript (#456)
cabf786 is described below

commit cabf786f09d1305a38684373a88c4e94f53a537c
Author: Jan Høydahl <[email protected]>
AuthorDate: Mon Dec 13 01:47:11 2021 +0100

    SOLR-15804 Support leading slash for "file" parameter, to mean relative to 
config dir. Support text/javascript (#456)
---
 .../java/org/apache/solr/handler/admin/ShowFileRequestHandler.java    | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java 
b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
index b657d97..0fd998d 100644
--- 
a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
@@ -105,6 +105,7 @@ public class ShowFileRequestHandler extends 
RequestHandlerBase implements Permis
   static {
     KNOWN_MIME_TYPES = new HashSet<>(MimeTypes.getKnownMimeTypes());
     KNOWN_MIME_TYPES.add("text/xml");
+    KNOWN_MIME_TYPES.add("text/javascript");
   }
 
   public ShowFileRequestHandler()
@@ -374,7 +375,8 @@ public class ShowFileRequestHandler extends 
RequestHandlerBase implements Permis
         rsp.setException(new SolrException( SolrException.ErrorCode.FORBIDDEN, 
"Can not access: "+fname ));
         return null;
       }
-      Path filePath = configdir.toPath().resolve(fname);
+      // A leading slash is unnecessary but supported and interpreted as start 
of config dir
+      Path filePath = configdir.toPath().resolve(fname.startsWith("/") ? 
fname.substring(1) : fname);
       req.getCore().getCoreContainer().assertPathAllowed(filePath);
       adminFile = filePath.toFile();
     }

Reply via email to