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

Check file upload size only if an upload limit has been imposed

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.1
    • 1.2
    • None

    Description

      The current implementation asks the request for the content length and exits if the stream does not know the size (i.e. -1).

      Within Bea portal this does not work because the action request always returns -1 for getContentLength.

      However, if the portal does not impose an upload limit, this hsould be ok.

      The problematic code snippet is

      int requestSize = ctx.getContentLength();

      if (requestSize == -1)

      { throw new UnknownSizeException( "the request was rejected because its size is unknown"); }

      if (sizeMax >= 0 && requestSize > sizeMax)

      { throw new SizeLimitExceededException( "the request was rejected because its size (" + requestSize + ") exceeds the configured maximum (" + sizeMax + ")", requestSize, sizeMax); }

      This should ne rewritten to

      int requestSize = ctx.getContentLength();

      if (sizeMax >= 0)
      {
      if (requestSize == -1) { throw new UnknownSizeException( "the request was rejected because its size is unknown"); }


      if(requestSize > sizeMax) { throw new SizeLimitExceededException( "the request was rejected because its size (" + requestSize + ") exceeds the configured maximum (" + sizeMax + ")", requestSize, sizeMax); }

      Attachments

        Activity

          People

            Unassigned Unassigned
            mark.vollmann Mark Vollmann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: