[
https://issues.apache.org/jira/browse/FILEUPLOAD-240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Thomas Neidhart resolved FILEUPLOAD-240.
----------------------------------------
Resolution: Duplicate
Closed as duplicate.
> Content-Disposition: attachment; does not work properly
> -------------------------------------------------------
>
> Key: FILEUPLOAD-240
> URL: https://issues.apache.org/jira/browse/FILEUPLOAD-240
> Project: Commons FileUpload
> Issue Type: Bug
> Affects Versions: 1.2.2, 1.3
> Reporter: Christoph Hartmann
> Labels: features
>
> 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.1.5#6160)