Uploaded image for project: 'Commons FileUpload'
  1. Commons FileUpload
  2. FILEUPLOAD-122

Filename may contain a full path

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Invalid
    • 1.1.1
    • None
    • None

    Description

      The filename extracted from the content disposition may contain a full path (i.e. as submitted by the Internet Explorer for example).

      It's is important to check for this and strip the path information accordingly as the upload fails if you use FileItem#getName() to build your destination path.

      I patched the abstract class FileUploadBase#getFileName(...) with a few lines of code inspired by COS' MultiPartParser

      Starting on line 447 (after fileName = fileName.trim(); )

      // The filename may contain a full path. Cut to just the filename.
      int slash = Math.max(fileName.lastIndexOf('/'), fileName.lastIndexOf('
      ')); // check for Unix AND Win separator
      if (slash > -1)

      { fileName = fileName.substring(slash + 1); // past last slash }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sbeigel Sebastian Beigel
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: