Issue Details (XML | Word | Printable)

Key: FILEUPLOAD-117
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Mark Vollmann
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons FileUpload

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

Created: 15/Sep/06 07:30 AM   Updated: 09/Mar/07 08:32 PM
Return to search
Component/s: None
Affects Version/s: 1.1.1
Fix Version/s: 1.2

Time Tracking:
Not Specified

Resolution Date: 31/Oct/06 05:58 AM


 Description  « Hide
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); } }



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Henri Yandell made changes - 30/Oct/06 11:56 PM
Field Original Value New Value
Comment [ Though I'd ping this on the list - anyone have any thoughts on this? Seems pretty simple. ]
Jochen Wiedmann made changes - 31/Oct/06 05:58 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 1.2 [ 12311929 ]
Henri Yandell made changes - 09/Mar/07 08:32 PM
Status Resolved [ 5 ] Closed [ 6 ]