Fix issue with parsing multipart body from unirest
Some libraries e.g. unirest always put Content-Type inside every chunk. Even though, it is a simple text/plain. This makes Sanic, mistakenly, treats that chunk as file. This commit made sure only chunks with "filename" after Content-Disposition are treated as files.
This commit is contained in:
parent
eb06e6ba51
commit
821a55c4aa
|
@ -265,7 +265,7 @@ def parse_multipart_form(body, boundary):
|
||||||
if 'filename' in form_parameters:
|
if 'filename' in form_parameters:
|
||||||
file_name = form_parameters['filename']
|
file_name = form_parameters['filename']
|
||||||
field_name = form_parameters.get('name')
|
field_name = form_parameters.get('name')
|
||||||
elif form_header_field == 'content-type':
|
elif form_header_field == 'content-type' and file_name:
|
||||||
file_type = form_header_value
|
file_type = form_header_value
|
||||||
|
|
||||||
post_data = form_part[line_index:-4]
|
post_data = form_part[line_index:-4]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user