-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebServer: Ignore extra headers within multipart forms #9253
Conversation
Update subpart ("PostArg") parsing to ignore extra headers instead of silently failing.
👋 Hello tcsullivan, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
@tcsullivan Can you please retest with 3.0.0-alpha3 version or latest master? Just to be sure :) |
@P-R-O-C-H-Y I just retested with 3.0.0-alpha3, the issue is still present. |
Description of Change
This Pull Request provides a fix for the WebServer library to ignore additional headers that may appear in
multipart/form-data
uploads. The current code assumes thatContent-Disposition
headers can only possibly be followed by aContent-Type
header, and while that is what the standard (RFC7578) intends, it is also required that any other headers be ignored (see related link).Currently, when extra header(s) are present the WebServer library will fail to properly locate the start of the submitted data. To fix this, the
Content-Type
check is simply wrapped in awhile
loop to skip over any additional headers.Tests scenarios
I have tested my Pull Request on Arduino-esp32 core v2.0.11 with an ESP32C3 Dev Module with this scenario:
Content-Length
:Content-Length
header and assume that the file data begins on the empty line that ends the header section, i.e. the WebServer will prepend the newline sequence0x0D 0x0A
to the received file data.With the provided fix, the header is ignored and the file upload is successful.
Related links
RFC 7578's requirement to ignore other header fields: https://www.rfc-editor.org/rfc/rfc7578#section-4.8
okhttp's fix, not yet in a stable release: square/okhttp#2604 (comment)