Default headerEncoding should be ISO-8859-1
-------------------------------------------
Key: FILEUPLOAD-161
URL: https://issues.apache.org/jira/browse/FILEUPLOAD-161
Project: Commons FileUpload
Issue Type: Bug
Affects Versions: 1.2.1
Reporter: Ignacio Coloma
When the browser does not include an encoding, commons-fileupload is using the
system default, but the standard says that it should be using ISO-8859-1:
https://bugzilla.mozilla.org/show_bug.cgi?id=241540
The post includes links to the RFC. This issue is related to FILEUPLOAD-56 and
FILEUPLOAD-100.
To reproduce this bug, try to upload a file including special characters from a
ISO-8859-1 browser (firefox or explorer on windows) to a UTF-8 server with
tomcat. The file contents arrive fine, but any special characters in the
filename get lost. A patch follows:
Index: src/java/org/apache/commons/fileupload/MultipartStream.java
===================================================================
--- src/java/org/apache/commons/fileupload/MultipartStream.java (revision
663089)
+++ src/java/org/apache/commons/fileupload/MultipartStream.java (working copy)
@@ -552,15 +552,11 @@
}
String headers = null;
- if (headerEncoding != null) {
- try {
- headers = baos.toString(headerEncoding);
- } catch (UnsupportedEncodingException e) {
- // Fall back to platform default if specified encoding is not
- // supported.
- headers = baos.toString();
- }
- } else {
+ try {
+ headers = baos.toString(headerEncoding != null? headerEncoding :
"ISO-8859-1");
+ } catch (UnsupportedEncodingException e) {
+ // Fall back to platform default if specified encoding is not
+ // supported.
headers = baos.toString();
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.