drogonframework / drogonframework/drogon

MultiPart parser returns -1 when file in form is not submitted

Open
#1,602 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

If I fill out a form containing a field with type="file" and do not upload a file, then the parser returns -1. This happens because this field is present in the headers, but the file name is empty. For example:

-----------------------------22269249813910642278816131791
Content-Disposition: form-data; name="photo"; filename=""
Content-Type: application/octet-stream

-----------------------------22269249813910642278816131791

My suggestion is to check the filename for null and don't try to get the contents of that file and don't return -1. See attached file.

[changes.txt](https://github.com/drogonframework/drogon/files/11454672/changes.txt)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.