-
Bug
-
Resolution: Fixed
-
Normal
-
8.0.0
-
Security Level: Jimmy
-
Servers: Tomcat/Jetty/(likely others) ... with enabled url-rewriting (enabled by default)
IE / FF / Safari?
(Chrome is unaffected)
-
ZK 8.5.2 S1, ZK 8.5.2 S2
-
None
The Filedownload.save method doesn't add the suggested file name to the HTTP header "Content-Disposition".
Code from zk 3.6.4 (Https.write):
if (download) { String value = "attachment"; final String flnm = media.getName(); if (flnm != null && flnm.length() > 0) value += ";filename=\"" + URLs.encode(flnm) +'"'; response.setHeader("Content-Disposition", value); //response.setHeader("Content-Transfer-Encoding", "binary"); }
Code from zk 8.0.0 (Https.write):
if (download) { String value = "attachment"; // Bug ZK-1257: Filedownload.save(media, filename) does not save the media as the specified filename StringBuffer temp = request.getRequestURL(); final String update_uri = (String)request.getSession().getServletContext().getAttribute("org.zkoss.zk.ui.http.update-uri"); //B65-ZK-1619 String flnm = ""; if (update_uri != null && temp.toString().contains(update_uri + "/view")) { // for Bug ZK-2350, we don't specify the filename when coming with ZK Fileupload, but invoke this directly as Bug ZK-1619 // final String saveAs = URLDecoder.decode(temp.substring(temp.lastIndexOf("/")+1), "UTF-8"); // flnm = ("".equals(saveAs)) ? media.getName() : saveAs; } else flnm = media.getName(); if (flnm != null && flnm.length() > 0) value += ";filename=" + encodeFilename(request, flnm); if (media.isContentDisposition()) response.setHeader("Content-Disposition", value); //response.setHeader("Content-Transfer-Encoding", "binary"); }
The 3.6.4 version adds the file name to the HTTP header.
The 8.0.0 only adds the file name to the HTTP header if the condition update_uri != null && temp.toString().contains(update_uri + "/view") is false. The condition is by default true because the request URL normally contains the string /zkau/view (update_uri + "/view").