Details
-
Type:
Improvement
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7.2 SP1
-
Component/s: ICE-Components
-
Labels:None
-
Environment:Linux, Windows, Mac OS X & IE, Safari, Firefox & Glassfish v2
-
ICEsoft Forum Reference:
Description
I think it's a bug of OutputResource, because instead of writing filename directly to Content-Disposition, it should encode it somehow first.
-
Hide
- c-s-jsp.war
- 8.05 MB
- yip.ng
-
- META-INF/MANIFEST.MF 0.1 kB
- WEB-INF/classes/.../NavigationBean.class 1 kB
- WEB-INF/classes/.../entity/Employee.class 2 kB
- WEB-INF/classes/org/.../entity/Person.class 1 kB
- WEB-INF/classes/.../EmployeeService.class 0.3 kB
- WEB-INF/.../EmployeeServiceImpl$1.class 0.3 kB
- WEB-INF/.../EmployeeServiceImpl$EmployeeComparator.class 3 kB
- WEB-INF/.../EmployeeServiceImpl.class 6 kB
- WEB-INF/classes/.../ContextUtilBean.class 3 kB
- WEB-INF/classes/.../util/FacesUtils.class 4 kB
- WEB-INF/classes/.../util/LocaleBean.class 3 kB
- WEB-INF/.../MessageBundleLoader.class 2 kB
- WEB-INF/.../RandomNumberGenerator.class 2 kB
- WEB-INF/.../SourceCodeLoaderServlet.class 3 kB
- WEB-INF/.../StyleBean$StylePath.class 1 kB
- WEB-INF/classes/org/.../util/StyleBean.class 3 kB
- WEB-INF/classes/org/.../bean/BaseBean.class 3 kB
- WEB-INF/classes/org/.../bean/BeanNames.class 0.7 kB
- WEB-INF/classes/.../NavigationNames.class 0.4 kB
- WEB-INF/classes/.../Inventory.class 2 kB
- WEB-INF/classes/.../InventoryInterface.class 0.5 kB
- WEB-INF/classes/.../InventoryItem.class 2 kB
- WEB-INF/.../ButtonsAndLinksBean.class 2 kB
- WEB-INF/classes/.../GroupingModel.class 0.8 kB
- WEB-INF/.../ColumnsBean$CellKey.class 1 kB
- WEB-INF/classes/.../ColumnsBean.class 5 kB
- WEB-INF/classes/.../SortHeaderModel.class 3 kB
- WEB-INF/classes/.../DataExporter.class 1 kB
- WEB-INF/.../DataScrollingModel$DataScrollMode.class 2 kB
- WEB-INF/classes/.../DataScrollingModel.class 3 kB
-
- fileName with '('.jpg
- 76 kB
-
- ScreenHunter_01.jpg
- 224 kB
-
- ScreenHunter_02.jpg
- 224 kB
-
- ScreenHunter_03.jpg
- 220 kB
-
- ScreenHunter_04.jpg
- 212 kB
-
- ScreenHunter_05.jpg
- 211 kB
-
- ScreenHunter_06.jpg
- 219 kB
-
- ScreenHunter_07.jpg
- 207 kB
-
- ScreenHunter_08.jpg
- 219 kB
-
- ScreenHunter_09.jpg
- 214 kB
-
- ScreenHunter_10.jpg
- 255 kB
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
See screenshots 08 - 10.
Added encoding of content disposition file name. This requires browser detection on the server side. Encoding for IE and Firefox is based on suggestion above from Robert Vojta. Other browsers and encoding methods may have to be added later case by case.
New .war file attached.
Hi Yip, thanks for testing war. I'll test it tomorrow.
I think it should be good to change behavior for Firefox & Operate to this one ...
http://greenbytes.de/tech/tc2231/#attwithfn2231utf8
Content-Disposition: attachment; filename*=UTF-8''foo-a%cc%88.html
... my solution for Firefox works because of wrong implementation in FF - probably will be fixed in the future. And I choosed it because I was able to add anything after "filename=" in OutputResource, but I wasn't able to use "attachment; filename*=" (see * before =) with OutputResource without source code modification. And as you're fixing it directly in the source code, it would be nice to have cleaner and more stable approach.
Mistake, second line s/Operate/Opera/, sorry.
Added detection for Opera. Changed encoding method for Firefox and Opera. (Required changes to other parts of OutputResource and ResourceDispatcher as well.)
New .war file attached.
Test instructions for QA:
In the component showcase demo for Download Resources, try the following names as the download file name:
€£ěščřžýáíéĚŠČŘŽÝÁÉ
Français+Español
Testingday_20_5__(a)_200907141213
The string ü@foo-bar
foo-%41
foo-ä
foo-ä-€
The popup save file dialog should display the proper file names on both IE and Firefox.
Also, try serving from Unix and downloading on Windows, and vice versa.
You can look at http://greenbytes.de/tech/tc2231/ for more info how this can be done. The problem is that there's no standard way how to do this for all browsers and you have to handle separate versions of IE as well
I've workaround with the following code in Java and I pass function return value to OutputResource filename parameter. This works for IE / Firefox ...
private static String encodeForIE(String fileName)
{ /* * http://greenbytes.de/tech/tc2231/#attwithfnrawpctenca * * IE decodes %XY to characters and than if it detects * UTF-8 stream (after decoding of %XY), than it creates * UTF-8 string. * * We use this behavior to offer correct file name * for download. */ StringBuilder encodedFileName = new StringBuilder(); encodedFileName.append("\""); // ICEfaces 1.7.2 bug encodedFileName.append(URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20")); encodedFileName.append("\""); // ICEfaces 1.7.2 bug return encodedFileName.toString(); }throws UnsupportedEncodingException
private static String encodeForFirefox(String fileName)
throws UnsupportedEncodingException {
/*
*
*
*/
StringBuilder encodedFileName = new StringBuilder();
encodedFileName.append("\""); // ICEfaces 1.7.2 bug
byte[] utf8Bytes = fileName.getBytes("UTF-8");
{ char ch = (char) b; encodedFileName.append(ch); }for (byte b : utf8Bytes)
encodedFileName.append("\""); // ICEfaces 1.7.2 bug
return encodedFileName.toString();
}