You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ni...@apache.org on 2006/02/14 03:21:30 UTC

svn commit: r377579 - /struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java

Author: niallp
Date: Mon Feb 13 18:21:28 2006
New Revision: 377579

URL: http://svn.apache.org/viewcvs?rev=377579&view=rev
Log:
Fix for Bug 34445 - use charsets given by browser for form field encodings - reported by Ralf Hauser.

Modified:
    struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java

Modified: struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java?rev=377579&r1=377578&r2=377579&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java Mon Feb 13 18:21:28 2006
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 package org.apache.struts.upload;
 
 import org.apache.commons.fileupload.DiskFileUpload;
+import org.apache.commons.fileupload.disk.DiskFileItem;
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.FileUploadException;
 import org.apache.commons.logging.Log;
@@ -46,8 +47,7 @@
  * interface by providing a wrapper around the Jakarta Commons FileUpload
  * library. </p>
  *
- * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
- *          $
+ * @version $Rev$ $Date$
  * @since Struts 1.1
  */
 public class CommonsMultipartRequestHandler implements MultipartRequestHandler {
@@ -380,7 +380,21 @@
         String name = item.getFieldName();
         String value = null;
         boolean haveValue = false;
-        String encoding = request.getCharacterEncoding();
+        String encoding = null;
+
+        if (item instanceof DiskFileItem) {
+            encoding = ((DiskFileItem)item).getCharSet();
+            if (log.isDebugEnabled()) {
+                log.debug("DiskFileItem.getCharSet=[" + encoding + "]");
+            }
+        }
+
+        if (encoding == null) {
+            encoding = request.getCharacterEncoding();
+            if (log.isDebugEnabled()) {
+                log.debug("request.getCharacterEncoding=[" + encoding + "]");
+            }
+        } 
 
         if (encoding != null) {
             try {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org