defnull / multipart

Multipart parser for Python 3
Other
120 stars 33 forks source link

improper handling of parts with no headers #10

Closed theelous3 closed 5 years ago

theelous3 commented 5 years ago

https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html

Specifically:

Note that the encapsulation boundary must occur at the beginning of a line, i.e., following a CRLF, and that that initial CRLF is considered to be part of the encapsulation boundary rather than part of the preceding part. The boundary must be followed immediately either by another CRLF and the header fields for the next part, or by two CRLFs, in which case there are no header fields for the next part (and it is therefore assumed to be of Content-Type text/plain).

An error is instead thrown.

multipart.MultipartError: Content-Disposition header is missing.

defnull commented 5 years ago

https://tools.ietf.org/html/rfc7578#section-4.2

Each part MUST contain a Content-Disposition header field [RFC2183] where the disposition type is "form-data". The Content-Disposition header field MUST also contain an additional parameter of "name"; the value of the "name" parameter is the original field name from the form (possibly encoded; see Section 5.1).

theelous3 commented 5 years ago

Ah. So the objective is only /form-data. Fair enough :)