Author: sichen
Date: Mon Jun 11 14:03:39 2007
New Revision: 546286
URL:
http://svn.apache.org/viewvc?view=rev&rev=546286Log:
Fix an upload encoding bug. OFBIZ-1072 from Krzysztof Podejma
Modified:
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java
Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java?view=diff&rev=546286&r1=546285&r2=546286==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java Mon Jun 11 14:03:39 2007
@@ -141,12 +141,15 @@
}
// directory used to temporarily store files that are larger than the configured size threshold
String tmpUploadRepository = UtilProperties.getPropertyValue("general.properties", "http.upload.tmprepository", "runtime/tmp");
-
+ String encoding = request.getCharacterEncoding();
// check for multipart content types which may have uploaded items
boolean isMultiPart = ServletFileUpload.isMultipartContent(request);
Map multiPartMap = new HashMap();
if (isMultiPart) {
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory(sizeThreshold, new File(tmpUploadRepository)));
+ if (encoding != null) {
+ upload.setHeaderEncoding(encoding);
+ }
upload.setSizeMax(maxUploadSize);
List uploadedItems = null;
@@ -177,7 +180,16 @@
Debug.logWarning("Form field found [" + fieldName + "] which was not handled!", module);
}
} else {
- multiPartMap.put(fieldName, item.getString());
+ if (encoding != null) {
+ try {
+ multiPartMap.put(fieldName, item.getString(encoding));
+ } catch (java.io.UnsupportedEncodingException uee){
+ Debug.logError(uee, "Unsupported Encoding, using deafault", module);
+ multiPartMap.put(fieldName, item.getString());
+ }
+ } else {
+ multiPartMap.put(fieldName, item.getString());
+ }
}
} else {
String fileName = item.getName();