Support RFC 2231
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 443
- Forks
- 206
- PR merge metrics
- No merged PRs in 30d
Description
When uploading files with non-ascii characters in the filename (using the requests library), the filename is encoded using RFC 2231. Example:
--shrubbery
Content-Disposition: form-data; name=test; filename*utf8''=a%5C.txt
ni
--shrubbery--
Presuming this is quite a common approach, I think it would be a nice addition to WebOb.
Currently, when trying to access the variables from the request, WebOb removes the filename from the body. Example:
import webob
import textwrap
post = textwrap.dedent("""
--spam
Content-Disposition: form-data; name="test"; filename*utf-8''="a%5Cb"
test
--spam--
""")
req = webob.Request.blank(
'/', POST=post,
content_type='multipart/form-data; boundary=spam')
original = str(req)
req.POST # This seems to modify the request.
self.assertEqual(original, str(req))
The filename being removed is not all that obvious. If unsupported parameters are removed, I think emitting a warning would be nice so developers receive a hint on why this is happening. If it isn't already, it should be documented.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied multipart/form-data example and tracing the request.POST multipart parsing path. Compare the parsed result and request body before and after access; done should preserve or appropriately handle RFC 2231 filenames, cover the reproduction with tests, and document or warn about unsupported parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100