commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Tompkins (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (FILEUPLOAD-239) Content-Disposition: attachment; does not work properly
Date Mon, 05 Jun 2017 13:54:04 GMT

     [ https://issues.apache.org/jira/browse/FILEUPLOAD-239?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Rob Tompkins closed FILEUPLOAD-239.
-----------------------------------

Invalid

> Content-Disposition: attachment; does not work properly
> -------------------------------------------------------
>
>                 Key: FILEUPLOAD-239
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-239
>             Project: Commons FileUpload
>          Issue Type: Bug
>    Affects Versions: 1.2.2, 1.3
>            Reporter: Christoph Hartmann
>
> If I submit data to a server as:
> {code:none}
> ----------------------------336962109586438949853174
> Content-Disposition: form-data; name="file"; filename="basketball.png"
> Content-Type: image/png
> content goes here
> ----------------------------336962109586438949853174--
> {code}
> the upload works as expected and FileUploadBase.findNextItem() recognize the image as
a file.
> But if I upload the file as 
> {code:none}
> --729ci2jje8exo4cr3u1h8kmis86ksupq
> Content-Type: image/png
> Content-Disposition: attachment; name="file"; filename="basketball.png
> content goes here
> --729ci2jje8exo4cr3u1h8kmis86ksupq
> {code}
>  FileUploadBase.findNextItem() does not recognize the image as a file. As specified in
http://www.ietf.org/rfc/rfc1867.txt this should according to the specification work.
> The problem is located in FileUploadBase.findNextItem() where we call
> {code:none}
> // We're parsing the outer multipart
> String fieldName = getFieldName(headers);
> {code}
> If I am right we should change the the following function:
> {code:none}
>     /**
>      * Returns the field name, which is given by the content-disposition
>      * header.
>      * @param pContentDisposition The content-dispositions header value.
>      * @return The field jake
>      */
>     private String getFieldName(String pContentDisposition) {
>         String fieldName = null;
>         if (pContentDisposition != null
>                 && pContentDisposition.toLowerCase().startsWith(FORM_DATA)) {
>             ParameterParser parser = new ParameterParser();
>             parser.setLowerCaseNames(true);
>             // Parameter parser can handle null input
>             Map params = parser.parse(pContentDisposition, ';');
>             fieldName = (String) params.get("name");
>             if (fieldName != null) {
>                 fieldName = fieldName.trim();
>             }
>         }
>         return fieldName;
>     }
> {code}
> Instead of if 
> {code:none}
> (pContentDisposition != null && pContentDisposition.toLowerCase().startsWith(FORM_DATA))
> {code} 
> we should use
> {code:none}
> (pContentDisposition != null && (pContentDisposition.toLowerCase().startsWith(FORM_DATA))
|| pContentDisposition.toLowerCase().startsWith(ATTACHMENT)))
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message