From 41a67c8d5fc0f466845e85626861c63ffc315191 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Mon, 13 Aug 2007 02:18:19 +0000 Subject: [PATCH] further simplified. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@4253 71c3de6d-444a-0410-be80-ed276b4c234a --- .../hudson/model/DirectoryBrowserSupport.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/model/DirectoryBrowserSupport.java b/core/src/main/java/hudson/model/DirectoryBrowserSupport.java index 445500215f..f2891c7212 100644 --- a/core/src/main/java/hudson/model/DirectoryBrowserSupport.java +++ b/core/src/main/java/hudson/model/DirectoryBrowserSupport.java @@ -66,24 +66,20 @@ public final class DirectoryBrowserSupport { * False to serve "index.html" */ public final void serveFile(StaplerRequest req, StaplerResponse rsp, FilePath root, String icon, boolean serveDirIndex) throws IOException, ServletException, InterruptedException { - String path = req.getRestOfPath(); - - if(path.length()==0) - path = "/"; - + String path = getPath(req); if(path.indexOf("..")!=-1) { // don't serve anything other than files in the artifacts dir rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } + // this is the "current" file/directory FilePath f = new FilePath(root,path.substring(1)); - String pattern = req.getParameter("pattern"); if(pattern==null) pattern = req.getParameter("path"); // compatibility with Hudson<1.129 - if (pattern != null) { + if (pattern != null) {// GLOB search servePattern(req, rsp, f, path, icon, pattern); return; } @@ -149,6 +145,13 @@ public final class DirectoryBrowserSupport { } } + private String getPath(StaplerRequest req) { + String path = req.getRestOfPath(); + if(path.length()==0) + path = "/"; + return path; + } + private void serveFileListing(StaplerRequest req, String path, FilePath dir, String icon, StaplerResponse rsp, List> files, String pattern) throws IOException, InterruptedException, ServletException { req.setAttribute("it",this); List parentPaths = buildParentPath(path);