Tapestry
  1. Tapestry
  2. TAPESTRY-1120

UploadPart / getFileName() doesn't work cross-platform

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0.2
    • Fix Version/s: 4.1.2
    • Component/s: Framework
    • Labels:
      None

      Description

      I could not reopen the issue http://issues.apache.org/bugzilla/show_bug.cgi?id=27544
      So I opened this one.

      The bug described by Karel Miarka is still not resolved. There is a bug in org.apache.tapestry.multipart.UploadPart 's getFileName method.:

      public String getFileName()
      {
      File file = new File(this.getFilePath());

      return file.getName();
      }

      You simply can not rely on JDK File implementation because it is not suitable to work cross-platform. Especially when uploading file from the MS IE client (on Windows of course to the unix-like server. MS IE sends full filename i.e. C:\Documents and Settings\user\Desktop\test.txt. This UploadPart implementation on the server use "/" character as a separator, therefore the file name could not be resolved.

      It would be appreciable if this bug would be fixed in the next release.

        Activity

        Hide
        Jesse Kuhnert added a comment -

        It already has been as far as I know...Try using 4.1.1

        Show
        Jesse Kuhnert added a comment - It already has been as far as I know...Try using 4.1.1
        Hide
        David Davis added a comment -

        I don't think this issue is quite closed yet...

        I ran into this problem while testing IE6/7 file uploading (on both linux and windows). Firefox on the same machine(s) worked.

        I did some empirical testing of 4.1.1, applying the patch for UploadPart.java that is in trunk (as of r516974) without successfully resolving the issue.

        Instead, this patch seems to work:
        {{{
        Index: org/apache/tapestry/multipart/UploadPart.java
        ===================================================================
        — org/apache/tapestry/multipart/UploadPart.java (revision 516974)
        +++ org/apache/tapestry/multipart/UploadPart.java (working copy)
        @@ -54,9 +54,10 @@
        */
        public String getFileName()

        { - File file = new File(FilenameUtils.separatorsToSystem(getFilePath())); - - return file.getName(); + // due to apparent bug in parsing the filename sent by IE 6, 7 + // https://issues.apache.org/jira/browse/TAPESTRY-1120 + // https://issues.apache.org/jira/browse/TAPESTRY-127 + return FilenameUtils.getName(getFilePath()); }

        /**
        }}}

        Show
        David Davis added a comment - I don't think this issue is quite closed yet... I ran into this problem while testing IE6/7 file uploading (on both linux and windows). Firefox on the same machine(s) worked . I did some empirical testing of 4.1.1, applying the patch for UploadPart.java that is in trunk (as of r516974) without successfully resolving the issue. Instead, this patch seems to work: {{{ Index: org/apache/tapestry/multipart/UploadPart.java =================================================================== — org/apache/tapestry/multipart/UploadPart.java (revision 516974) +++ org/apache/tapestry/multipart/UploadPart.java (working copy) @@ -54,9 +54,10 @@ */ public String getFileName() { - File file = new File(FilenameUtils.separatorsToSystem(getFilePath())); - - return file.getName(); + // due to apparent bug in parsing the filename sent by IE 6, 7 + // https://issues.apache.org/jira/browse/TAPESTRY-1120 + // https://issues.apache.org/jira/browse/TAPESTRY-127 + return FilenameUtils.getName(getFilePath()); } /** }}}
        Hide
        David Davis added a comment -

        Is it possible to 're-open' a ticket, or should I create a sub-task instead?

        Show
        David Davis added a comment - Is it possible to 're-open' a ticket, or should I create a sub-task instead?
        Hide
        Jesse Kuhnert added a comment -

        Applied suggestion, thanks.

        Show
        Jesse Kuhnert added a comment - Applied suggestion, thanks.

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Martin Petras
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development