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

hapylestat pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new c0bef35  AMBARI-25545 Downloaded zip-file name shows empty in the 
fileview (#3220) (akiyamaneko via dgrinenko)
c0bef35 is described below

commit c0bef351b416d0b0cbdd0ceffa8d8cea7372a8c9
Author: neko <[email protected]>
AuthorDate: Tue Sep 29 18:55:54 2020 +0800

    AMBARI-25545 Downloaded zip-file name shows empty in the fileview (#3220) 
(akiyamaneko via dgrinenko)
---
 .../java/org/apache/ambari/view/filebrowser/DownloadService.java   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
 
b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
index 81ac40d..e7ea16b 100644
--- 
a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
+++ 
b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
@@ -62,6 +62,7 @@ import java.util.Queue;
 import java.util.UUID;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
+import java.net.URLEncoder;
 
 /**
  * Service for download and aggregate files
@@ -113,12 +114,12 @@ public class DownloadService extends HdfsService {
       ResponseBuilder result = Response.ok(fs);
       if (download) {
         result.header("Content-Disposition",
-          "attachment; filename=\"" + status.getPath().getName() + 
"\"").type(MediaType.APPLICATION_OCTET_STREAM);
+          "attachment; filename=\"" + 
URLEncoder.encode(status.getPath().getName(), "UTF-8") + 
"\"").type(MediaType.APPLICATION_OCTET_STREAM);
       } else {
         FileNameMap fileNameMap = URLConnection.getFileNameMap();
         String mimeType = 
fileNameMap.getContentTypeFor(status.getPath().getName());
         result.header("Content-Disposition",
-          "filename=\"" + status.getPath().getName() + "\"").type(mimeType);
+          "filename=\"" + URLEncoder.encode(status.getPath().getName(), 
"UTF-8") + "\"").type(mimeType);
       }
       return result.build();
     } catch (WebApplicationException ex) {
@@ -228,7 +229,7 @@ public class DownloadService extends HdfsService {
         }
       };
       return Response.ok(result)
-          .header("Content-Disposition", "inline; filename=\"" + name 
+"\"").build();
+          .header("Content-Disposition", "inline; filename=\"" + 
URLEncoder.encode(name, "UTF-8") +"\"").build();
     } catch (WebApplicationException ex) {
       LOG.error("Error occurred : ",ex);
       throw ex;

Reply via email to