rack/rack — Issue #323: Multipart filename can not be decoded.
Author: comron
Created: 2012-01-21 00:44:18+00:00
State: open

I'm using a simple form on a rails application to upload a file, it looks as if the browser is not encoding the filename in the multipart "Content-Disposition" header, and as a result rack cannot decode the filename if it has a % in it, as it expects this to be the start of an escape sequence.

```

```

Results in the following request

```
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary2NHc7OhsgU68l3Al
Origin:http://localhost:3000
Referer:http://localhost:3000/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.18 (KHTML, like Gecko) Chrome/18.0.1010.0 Safari/535.18

------WebKitFormBoundary2NHc7OhsgU68l3Al
Content-Disposition: form-data; name="utf8"

âœ“
------WebKitFormBoundary2NHc7OhsgU68l3Al
Content-Disposition: form-data; name="document[attachment]"; filename="100% of a photo.jpeg"
Content-Type: image/jpeg

------WebKitFormBoundary2NHc7OhsgU68l3Al--
```

As you can see the filename is not encoded, but the % causes rack to throw an error. Where exactly is the problem? It seems I have no control over the browser (Chrome and Firefox on OS X) encoding this name, and rack assumes it is always encoded, in multipart/parser.rb.

Thanks and sorry if this is the wrong forum for such a question.