You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Racon (JIRA)" <ji...@apache.org> on 2007/06/08 17:13:26 UTC

[jira] Commented: (WW-1911) Content-Type validation when no file is uploaded

    [ https://issues.apache.org/struts/browse/WW-1911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41200 ] 

Lukasz Racon commented on WW-1911:
----------------------------------

Same issue:
https://issues.apache.org/struts/browse/WW-1976

> Content-Type validation when no file is uploaded
> ------------------------------------------------
>
>                 Key: WW-1911
>                 URL: https://issues.apache.org/struts/browse/WW-1911
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Dispatch, Interceptors
>    Affects Versions: 2.0.6, 2.0.7, 2.1.0, 2.1.x
>         Environment: FireFox 2.0; Tomcat 5.0; commons-fileupload 1.2
>            Reporter: Lukasz Racon
>             Fix For: 2.0.9
>
>         Attachments: patch.txt
>
>
> 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 uploaded.

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