commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christoph Hartmann (JIRA)" <>
Subject [jira] [Created] (FILEUPLOAD-240) Content-Disposition: attachment; does not work properly
Date Sun, 10 Nov 2013 14:10:18 GMT
Christoph Hartmann created FILEUPLOAD-240:

             Summary: Content-Disposition: attachment; does not work properly
                 Key: FILEUPLOAD-240
             Project: Commons FileUpload
          Issue Type: Bug
    Affects Versions: 1.3, 1.2.2
            Reporter: Christoph Hartmann

If I submit data to a server as:

Content-Disposition: form-data; name="file"; filename="basketball.png"
Content-Type: image/png
content goes here

the upload works as expected and FileUploadBase.findNextItem() recognize the image as a file.

But if I upload the file as 
Content-Type: image/png
Content-Disposition: attachment; name="file"; filename="basketball.png
content goes here

 FileUploadBase.findNextItem() does not recognize the image as a file. As specified in
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();
            // 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)))

This message was sent by Atlassian JIRA

View raw message