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.
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
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)
throws UnsupportedEncodingException
private static String encodeForFirefox(String fileName)
throws UnsupportedEncodingException {
/*
- http://greenbytes.de/tech/tc2231/#attwithutf8fnplain
* - Firefox is trying to be smart and decodes UTF-8 characters
- written as ISO-8859-1 bytes as UTF-8.
* - We use this Firefox behavior to offer correct file name
- for download.
*/
StringBuilder encodedFileName = new StringBuilder();
encodedFileName.append("\""); // ICEfaces 1.7.2 bug
byte[] utf8Bytes = fileName.getBytes("UTF-8");
for (byte b : utf8Bytes)
encodedFileName.append("\""); // ICEfaces 1.7.2 bug
return encodedFileName.toString();
}
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.