ICEfaces
  1. ICEfaces
  2. ICE-2237

Can't upload very small files when SSL is enabled

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.7RC1, 1.7
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      jsf 1.2, jboss 4.2, windows

      Description

       There seems to be a bug in apache file upload 1.2 which causes files which are 44 bytes or less to not be uploaded.

      44 bytes is the length of the delimiter between parts of the multi-part stream. It seems that if the contents of the file is less than the size of the stream delimiter, then the input stream returns 0 bytes from the stream.
      1. screenshot-1.jpg
        152 kB
      2. screenshot-2.jpg
        187 kB
      3. screenshot-3.jpg
        156 kB

        Activity

        Philip Breau created issue -
        Philip Breau made changes -
        Field Original Value New Value
        Support Case References https://www.icesoft.ca:4443/supportilla/show_bug.cgi?id=4379
        Hide
        Philip Breau added a comment -

        suggested fix:

        Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/inputfile/InputFile.java
        ===================================================================
        — D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/inputfile/InputFile.java (revision 15197)
        +++ D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/inputfile/InputFile.java (working copy)
        @@ -59,7 +59,7 @@
        import java.io.File;
        import java.io.FileOutputStream;
        import java.io.IOException;
        -import java.io.OutputStream;
        +import java.io.FileWriter;
        import java.io.Serializable;
        import java.io.Writer;
        import java.util.ArrayList;
        @@ -67,6 +67,7 @@
        import java.util.Iterator;

        +
        /**

        • InputFile is a JSF component class representing an ICEfaces inputFile.
          */
          @@ -195,15 +196,29 @@
          if (!folderFile.exists())
          folderFile.mkdirs();
          file = new File(folder, fileName);
        • OutputStream output = new FileOutputStream(file);
        • Streams.copy(stream.openStream(), output, true);
        • if (file.length() == 0) { - setProgress(0); - file.delete(); - throw new FileUploadBase.FileUploadIOException( - new FileUploadBase.InvalidContentTypeException()); - }
        • status = SAVED;
          + FileOutputStream output = new FileOutputStream(file);
          + byte[] buff = new byte[8192];
          + Streams.copy(stream.openStream(), output, true, buff);
          +
          + //ICE-2237 workaround for Commons File Upload not properly
          + //uploading small files through SSL
          + if (file.length() == 0 && buff[0] != 0)
          Unknown macro: {+ StringBuffer strBuff = new StringBuffer(8192);+ byte b = buff[0];+ int i = 0;+ while (b != 0) { + strBuff.append(b); + i++; + b = buff[i]; + }+ FileWriter out = new FileWriter(file);+ out.write(strBuff.toString());+ }

          else if (file.length() == 0)

          { + setProgress(0); + file.delete(); + throw new FileUploadBase.FileUploadIOException( + new FileUploadBase.InvalidContentTypeException()); + }

          status = SAVED;
          fileInfo.setPhysicalPath(file.getAbsolutePath());
          updateFileValueBinding(context);
          notifyDone(bfc);

        Show
        Philip Breau added a comment - suggested fix: Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/inputfile/InputFile.java =================================================================== — D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/inputfile/InputFile.java (revision 15197) +++ D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/inputfile/InputFile.java (working copy) @@ -59,7 +59,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStream; +import java.io.FileWriter; import java.io.Serializable; import java.io.Writer; import java.util.ArrayList; @@ -67,6 +67,7 @@ import java.util.Iterator; + /** InputFile is a JSF component class representing an ICEfaces inputFile. */ @@ -195,15 +196,29 @@ if (!folderFile.exists()) folderFile.mkdirs(); file = new File(folder, fileName); OutputStream output = new FileOutputStream(file); Streams.copy(stream.openStream(), output, true); if (file.length() == 0) { - setProgress(0); - file.delete(); - throw new FileUploadBase.FileUploadIOException( - new FileUploadBase.InvalidContentTypeException()); - } status = SAVED; + FileOutputStream output = new FileOutputStream(file); + byte[] buff = new byte [8192] ; + Streams.copy(stream.openStream(), output, true, buff); + + // ICE-2237 workaround for Commons File Upload not properly + //uploading small files through SSL + if (file.length() == 0 && buff [0] != 0) Unknown macro: {+ StringBuffer strBuff = new StringBuffer(8192);+ byte b = buff[0];+ int i = 0;+ while (b != 0) { + strBuff.append(b); + i++; + b = buff[i]; + }+ FileWriter out = new FileWriter(file);+ out.write(strBuff.toString());+ } else if (file.length() == 0) { + setProgress(0); + file.delete(); + throw new FileUploadBase.FileUploadIOException( + new FileUploadBase.InvalidContentTypeException()); + } status = SAVED; fileInfo.setPhysicalPath(file.getAbsolutePath()); updateFileValueBinding(context); notifyDone(bfc);
        Ken Fyten made changes -
        Fix Version/s 1.7DR#3 [ 10112 ]
        Assignee Yip Ng [ yip.ng ]
        Hide
        yip.ng added a comment -

        Screenshot showing the problem. The file to upload, Document1.txt, has just one character in it.

        Show
        yip.ng added a comment - Screenshot showing the problem. The file to upload, Document1.txt, has just one character in it.
        yip.ng made changes -
        Attachment screenshot-1.jpg [ 10753 ]
        Hide
        yip.ng added a comment -

        Suggested fix didn't seem to work. Still got the same error.

        Show
        yip.ng added a comment - Suggested fix didn't seem to work. Still got the same error.
        Hide
        yip.ng added a comment -

        The fix was originally tested on Tomcat 5.0.28. Didn't work. I just tested it again on Tomcat 5.5.25. Didn't work either.

        Show
        yip.ng added a comment - The fix was originally tested on Tomcat 5.0.28. Didn't work. I just tested it again on Tomcat 5.5.25. Didn't work either.
        Hide
        yip.ng added a comment -

        Seems the problem occurs only on Firefox. On IE it works fine, even without the suggested fix.

        Show
        yip.ng added a comment - Seems the problem occurs only on Firefox. On IE it works fine, even without the suggested fix.
        yip.ng made changes -
        Attachment screenshot-2.jpg [ 10758 ]
        Hide
        yip.ng added a comment -

        Tested modifying the file upload component to use the commons file upload traditional API instead of the streaming API. Same problem. So it's not just a problem with the streaming API, but something more general. (Again, IE worked fine. Only Firefox had the problem.)

        Show
        yip.ng added a comment - Tested modifying the file upload component to use the commons file upload traditional API instead of the streaming API. Same problem. So it's not just a problem with the streaming API, but something more general. (Again, IE worked fine. Only Firefox had the problem.)
        Ken Fyten made changes -
        Fix Version/s 1.7 [ 10080 ]
        Fix Version/s 1.7DR#3 [ 10112 ]
        Assignee Yip Ng [ yip.ng ] Philip Breau [ philip.breau ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #15361 Wed Dec 12 17:49:13 MST 2007 yip.ng ICE-2237
        Set minimum width of input + button fields of popup calendar.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java
        Show
        Philip Breau added a comment - Issue is now fixed in commons-fileupload https://issues.apache.org/jira/browse/FILEUPLOAD-135 1.3 snapshot build: http://people.apache.org/repo/m2-snapshot-repository/org/apache/commons/fileupload/commons-fileupload/1.3-SNAPSHOT/
        Hide
        Ken Fyten added a comment -

        Once an official file-upload release occurs we should update our version to resolve this issue.

        Show
        Ken Fyten added a comment - Once an official file-upload release occurs we should update our version to resolve this issue.
        Ken Fyten made changes -
        Assignee Philip Breau [ philip.breau ] Yip Ng [ yip.ng ]
        Hide
        Ken Fyten added a comment -

        Let's go ahead and update to the latest 1.3 milestone for 1.7. Philip reports is solves the problem and we can't wait any longer for an official release.

        Please remember to update the "LicensesAndVersions.html" in the icefaces/lib/ directory to reflect the correct version number for the new .jar.

        Show
        Ken Fyten added a comment - Let's go ahead and update to the latest 1.3 milestone for 1.7. Philip reports is solves the problem and we can't wait any longer for an official release. Please remember to update the "LicensesAndVersions.html" in the icefaces/lib/ directory to reflect the correct version number for the new .jar.
        Ken Fyten made changes -
        Affects [Documentation (User Guide, Ref. Guide, etc.)]
        Assignee Priority P1
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #15812 Fri Feb 15 11:43:53 MST 2008 yip.ng ICE-2237
        New version (1.3-SNAPSHOT) to fix bug in https file upload of small files from Firefox.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/lib/commons-fileupload.jar
        Commit graph MODIFY /icefaces/trunk/icefaces/lib/versions-licenses.html
        Hide
        yip.ng added a comment -

        Screenshot showing that the new commons-fileupload fixed the problem in Firefox.

        Show
        yip.ng added a comment - Screenshot showing that the new commons-fileupload fixed the problem in Firefox.
        yip.ng made changes -
        Attachment screenshot-3.jpg [ 10821 ]
        Hide
        yip.ng added a comment -

        How to test:

        Follow the instructions at http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html to set up SSL. Then create a small file (e.g. 1 byte) and upload it from Firefox. See the screenshots for the https URL to use to access component showcase in SSL.

        Show
        yip.ng added a comment - How to test: Follow the instructions at http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html to set up SSL. Then create a small file (e.g. 1 byte) and upload it from Firefox. See the screenshots for the https URL to use to access component showcase in SSL.
        yip.ng made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Ken Fyten made changes -
        Fix Version/s 1.7RC1 [ 10123 ]
        Fix Version/s 1.7 [ 10080 ]
        Ken Fyten made changes -
        Fix Version/s 1.7 [ 10080 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Priority P1
        Assignee Yip Ng [ yip.ng ]
        Hide
        Joanne Bai added a comment -

        QA successfully tested it on ICEfaces trunk subversion 18006 + tomcat 6 on FF2, IE6, IE7, and opera9.2

        Test Steps:

        • log onto QA server lnqa0 (10.18.39.15)
        • fire up tomcat 6 under /opt/apache-tomcat-6.0.16
        • deploy component showcase to the webapps folder
        • access showcase via https://lnqa0.ice/component-showcase
        • create a small enough file and try uploading it
        Show
        Joanne Bai added a comment - QA successfully tested it on ICEfaces trunk subversion 18006 + tomcat 6 on FF2, IE6, IE7, and opera9.2 Test Steps: log onto QA server lnqa0 (10.18.39.15) fire up tomcat 6 under /opt/apache-tomcat-6.0.16 deploy component showcase to the webapps folder access showcase via https://lnqa0.ice/component-showcase create a small enough file and try uploading it

          People

          • Assignee:
            Unassigned
            Reporter:
            Philip Breau
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: