struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukasz Racon (JIRA)" <>
Subject [jira] Created: (WW-1911) Content-Type validation when no file is uploaded
Date Sun, 06 May 2007 05:37:42 GMT
Content-Type validation when no file is uploaded

                 Key: WW-1911
             Project: Struts 2
          Issue Type: Bug
          Components: Dispatch, Interceptors
    Affects Versions: 2.0.7, 2.0.6, 2.1.0, 2.1.x
         Environment: FireFox 2.0; Tomcat 5.0; commons-fileupload 1.2
            Reporter: Lukasz Racon

If you set allowed types on the file upload interceptor:
<param name="fileUpload.allowedTypes">image/png,image/gif,image/jpeg</param>

it will validate content type even though there is no file uploaded. 
This shows up in two cases:
1) If field is required you will get 2 messages:
Content-Type not allowed: image "upload_1120a017_1125f7d74fc__8000_00000013.tmp" application/octet-stream
Image is required.

2) If field is not required you will get invalid content type validation error anyway (which
prohibits from executing the action):
Content-Type not allowed: image "upload_1120a017_1125f7d74fc__8000_00000013.tmp" application/octet-stream

Basically it violates the idea of single purpose validator (since it also acts as required
field validator).

There are at least 3 ways to fix it:
1) fix org.apache.struts2.interceptor.FileUploadInterceptor.acceptFile method so it does not
check content type (allowedTypesSet) if file is empty.
2) fix the ServletFileUpload.parseRequest so it does not show empty downloads (i.e. when file
name is null). 
3) (one that is in patch) fix org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest.parse
so it ignores files that have blank file name.

Attached patch fixes JakartaMultiPartRequest if file name is blank it means no file has been

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message