Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
1.2.2, 1.3
-
None
-
None
Description
If I submit data to a server as:
----------------------------336962109586438949853174 Content-Disposition: form-data; name="file"; filename="basketball.png" Content-Type: image/png content goes here ----------------------------336962109586438949853174--
the upload works as expected and FileUploadBase.findNextItem() recognize the image as a file.
But if I upload the file as
--729ci2jje8exo4cr3u1h8kmis86ksupq Content-Type: image/png Content-Disposition: attachment; name="file"; filename="basketball.png content goes here --729ci2jje8exo4cr3u1h8kmis86ksupq
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
// We're parsing the outer multipart String fieldName = getFieldName(headers);
If I am right we should change the the following function:
/** * 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; }
Instead of if
(pContentDisposition != null && pContentDisposition.toLowerCase().startsWith(FORM_DATA))
we should use
(pContentDisposition != null && (pContentDisposition.toLowerCase().startsWith(FORM_DATA)) || pContentDisposition.toLowerCase().startsWith(ATTACHMENT)))
Attachments
Issue Links
- is duplicated by
-
FILEUPLOAD-240 Content-Disposition: attachment; does not work properly
-
- Closed
-