Commits

Anonymous committed b4a3971

Bruce's patch to fix IE 6 sp2 problem

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@506573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (1)

src/java/com/opensymphony/webwork/dispatcher/multipart/JakartaMultiPartRequest.java

         return (File[]) fileList.toArray(new File[fileList.size()]);
     }
 
+    /**
+     * Returns the canonical name of the given file
+     */
+    private String getCanonicalName(String filename) {
+        int forwardSlash = filename.lastIndexOf("/");
+        int backwardSlash = filename.lastIndexOf("\\");
+        if (forwardSlash != -1 && forwardSlash > backwardSlash) {
+            filename = filename.substring(forwardSlash + 1, filename.length());
+        } else if (backwardSlash != -1 && backwardSlash >= forwardSlash) {
+            filename = filename.substring(backwardSlash + 1, filename.length());
+        }
+
+        return filename;
+    }
+
     public String[] getFileNames(String fieldName) {
         List items = (List) files.get(fieldName);
 
         List fileNames = new ArrayList(items.size());
         for (int i = 0; i < items.size(); i++) {
             DefaultFileItem fileItem = (DefaultFileItem) items.get(i);
-            fileNames.add(fileItem.getName());
+            fileNames.add(getCanonicalName(fileItem.getName()));
         }
 
         return (String[]) fileNames.toArray(new String[fileNames.size()]);