Skip header area?
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Start at MultipartParser._internal_write and reproduce the reported input generated by email.mime.multipart.MIMEMultipart and as_string(). Trace how the parser handles the initial MIME-Version header and the CRLFCRLF boundary, then verify that multipart payloads with this header area are accepted without breaking browser-style uploads.
Written by the indexing model from the issue text.
Description
RFC 1341 says about multipart payloads:
This [the multipart content-type] indicates that the entity consists of several parts, each itself with a structure that is syntactically identical to an RFC 822 message, except that the header area might be completely empty...
I read that as: "a multipart payload may have a header area". As a matter of fact, when you construct a multipart payload using email.mime.multipart.MIMEMultipart and then calling as_string(), you get:
MIME-Version: 1.0
Content-Type: multipart/form-data; boundary="========== bounda r y 930"
--========== bounda r y 930\nMIME-Version: 1.0
Content-Type: application/octet-stream
...
The multipart parser from the old cgi module would correctly grok that when I uploaded it (provided I arranged for the content-type to be in the HTTP header). python-multipart (tried 0.0.5) does not and fails when it sees the M of the MIME-Version.
I appreciate the "as browsers send it" part of multipart's rationale; however, being somewhat friendly to machine-generated multipart messages would, I think, be a friendly gesture, and it might prevent breakage as people move from cgi's FieldStorage (used, e.g., in twisted) to python-multipart.
What I think should be done: in MultipartParser's _internal_write, we should blindly skip everything until the MIME header area is consumed, i.e., until we have found a CRLFCRLF sequence. Would you consider such a PR?
- Dominant language
- Python
- Stars
- 539
- Forks
- 109
- Avg merge
- 6h 35m
- Merged PRs (30d)
- 20
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from Kludex/python-multipart
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kludex/python-multipart#375 ·
Maintainers usually reply within 1 day
-
Clarify or handle non-Latin-1 str input in parse_options_headerMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Kludex/python-multipart#319 · 1 comment ·
Maintainers usually reply within 1 day
All issues in Kludex/python-multipart
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 3 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 11 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
FuRongJun-1999/dsh-memory#1000 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gcivil-nyu-org/team5-mon-fall26#154 ·
Maintainers usually reply within 1 day
-
docs: reorder interface definition before fetch-libs and link PostgreSQL/library docs in tutorialOpen
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 3 days