diff --git a/core/src/main/java/hudson/model/FileParameterValue.java b/core/src/main/java/hudson/model/FileParameterValue.java index 239adf546422c3cd8b186fbdf5f85ebe4348d01c..8a8494a9d5af545f39f71236693f33f7577ca715 100644 --- a/core/src/main/java/hudson/model/FileParameterValue.java +++ b/core/src/main/java/hudson/model/FileParameterValue.java @@ -226,46 +226,11 @@ public class FileParameterValue extends ParameterValue { * * @param request * @param response - * @throws ServletException - * @throws IOException */ - public void doDynamic(StaplerRequest request, StaplerResponse response) throws ServletException, IOException { - if (("/" + originalFileName).equals(request.getRestOfPath())) { - AbstractBuild build = (AbstractBuild)request.findAncestor(AbstractBuild.class).getObject(); - File fileParameter = getLocationUnderBuild(build); - - if (!ALLOW_FOLDER_TRAVERSAL_OUTSIDE_WORKSPACE) { - File fileParameterFolder = getFileParameterFolderUnderBuild(build); - - //TODO can be replaced by Util#isDescendant in 2.80+ - Path child = fileParameter.getAbsoluteFile().toPath().normalize(); - Path parent = fileParameterFolder.getAbsoluteFile().toPath().normalize(); - if (!child.startsWith(parent)) { - throw new IllegalStateException("The fileParameter tried to escape the expected folder: " + location); - } - } - - if (fileParameter.isFile()) { - try (InputStream data = Files.newInputStream(fileParameter.toPath())) { - long lastModified = fileParameter.lastModified(); - long contentLength = fileParameter.length(); - if (request.hasParameter("view")) { - response.serveFile(request, data, lastModified, contentLength, "plain.txt"); - } else { - String csp = SystemProperties.getString(DirectoryBrowserSupport.class.getName() + ".CSP", DirectoryBrowserSupport.DEFAULT_CSP_VALUE); - if (!csp.trim().equals("")) { - // allow users to prevent sending this header by setting empty system property - for (String header : new String[]{"Content-Security-Policy", "X-WebKit-CSP", "X-Content-Security-Policy"}) { - response.setHeader(header, csp); - } - } - response.serveFile(request, data, lastModified, contentLength, originalFileName); - } - } catch (InvalidPathException e) { - throw new IOException(e); - } - } - } + public DirectoryBrowserSupport doDynamic(StaplerRequest request, StaplerResponse response) { + AbstractBuild build = (AbstractBuild)request.findAncestor(AbstractBuild.class).getObject(); + File fileParameter = getFileParameterFolderUnderBuild(build); + return new DirectoryBrowserSupport(build, new FilePath(fileParameter), Messages.FileParameterValue_IndexTitle(), "folder.png", false); } /** diff --git a/core/src/main/resources/hudson/model/FileParameterValue/value.jelly b/core/src/main/resources/hudson/model/FileParameterValue/value.jelly index 0afcb71564dab75525780e65692a8792eadf1a23..6f8113b2c98727ec465c1dd44a8d94c2cb118576 100644 --- a/core/src/main/resources/hudson/model/FileParameterValue/value.jelly +++ b/core/src/main/resources/hudson/model/FileParameterValue/value.jelly @@ -26,16 +26,23 @@ THE SOFTWARE. - - - - - - - - ${it.originalFileName} - - ${%view} - + + + + + + + + + ${%open} + + ${%view} + + + + ${%nofile} + + + \ No newline at end of file diff --git a/core/src/main/resources/hudson/model/FileParameterValue/value.properties b/core/src/main/resources/hudson/model/FileParameterValue/value.properties new file mode 100644 index 0000000000000000000000000000000000000000..e487643ec2db5689ae63c62a7d3c6c006a36e5da --- /dev/null +++ b/core/src/main/resources/hudson/model/FileParameterValue/value.properties @@ -0,0 +1 @@ +nofile=(No file was uploaded) diff --git a/core/src/main/resources/hudson/model/Messages.properties b/core/src/main/resources/hudson/model/Messages.properties index fe9925d6ac717f847cca621c72338d1b4a228c4d..0450809463f8b45677e4aa44cbe47df279d2384f 100644 --- a/core/src/main/resources/hudson/model/Messages.properties +++ b/core/src/main/resources/hudson/model/Messages.properties @@ -412,3 +412,5 @@ ManagementLink.Category.TROUBLESHOOTING=Troubleshooting ManagementLink.Category.TOOLS=Tools and Actions ManagementLink.Category.MISC=Other ManagementLink.Category.UNCATEGORIZED=Uncategorized + +FileParameterValue.IndexTitle=File Parameters