Author: xlawrence
Date: Fri Jun  1 14:55:57 2007
New Revision: 17442

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D17442&repname=
=3Djahia
Log:
Fix encoding issue. Set the default decoding charset to UTF-8

Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/tools/files/FileUp=
load.java

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/tools/files/=
FileUpload.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/tools/files/FileUpload.java&rev=3D17442&rep=
name=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/tools/files/FileUp=
load.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/tools/files/FileUp=
load.java Fri Jun  1 14:55:57 2007
@@ -45,6 +45,7 @@
 =

     private static final org.apache.log4j.Logger logger =3D
         org.apache.log4j.Logger.getLogger (FileUpload.class);
+    private static final String UTF_8 =3D "UTF-8";
 =

     private Map params;
     private Map files;
@@ -53,6 +54,7 @@
 =

     private String savePath =3D "";
     private int fileMaxSize;
+    private String encoding;
 =

     /**
      * Constructor
@@ -69,6 +71,32 @@
         this.req =3D req;
         this.fileMaxSize =3D fileMaxSize;
         this.savePath =3D savePath;
+        this.encoding =3D UTF_8;
+        init();
+    }
+
+    /**
+     * Constructor
+     *
+     * @param req
+     * @param savePath    the path where files should be saved
+     * @param fileMaxSize the max size of file to upload
+     * @param charset The charset to use to decode the values (default =3D=
 UTF-8)
+     */
+    public FileUpload(final HttpServletRequest req,
+                      final String savePath,
+                      final int fileMaxSize,
+                      final String charset)
+            throws IOException {
+
+        this.req =3D req;
+        this.fileMaxSize =3D fileMaxSize;
+        this.savePath =3D savePath;
+        if (charset =3D=3D null) {
+            this.encoding =3D UTF_8;
+        } else {
+            this.encoding =3D charset;
+        }
         init();
     }
 =

@@ -108,7 +136,7 @@
                             v =3D new ArrayList();
                             params.put(name,v);
                         }
-                        v.add(item.getString());
+                        v.add(item.getString(encoding));
                     } else {
                         if (item.getSize() > 0) {
                             files.put(item.getStoreLocation().getName(), i=
tem);

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to