-
Notifications
You must be signed in to change notification settings - Fork 7.6k
WebServer file upload fails when file ends with "--\r\n". #9163
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
Comments
@everslick since you already have a test case, could you please try and figure out where does it exactly fail in that function. In reality it should not break, but instead figure out that this is not the searched for string and give it to the file processor. Maybe some edge case that we have not thought of |
I tracked it down as far as I could. The _parseForm() method is aborted in line https://github.com/espressif/arduino-esp32/blob/master/libraries/WebServer/src/Parsing.cpp#L452
ESP8266 to the rescue! ;-) |
I have opened #9167 for a proposed fix. Please review carefully. |
The _uploadReadByte() method should also be replaced with this implementation from ESP8266:
|
did you try with just replacing that? |
No, I did not. But, let me explain... I maintain my own fork of the WebServer library since approx. 4 years, because I need some changes that are not relevant for upstreaming. That fork is compatible with ESP32 and ESP8266 and also had already a different Still, I did not try to understand the bug, nor do I know, if this is a complete solution. Nevertheless the code from ESP8266 looks much saner and is much shorter anyway, so I think it's worth to give it a shot. Having said that, we can as well wait some days and see if anything comes up here on my side with more testing. Who knows whats still lurking in there. ;-) |
regardless, your issue you pointed at |
@everslick Could you provide the sketch or example that you used to test this issue ? |
I don't have one. And I don't even have Arduino installed. But I believe that the https://github.com/espressif/arduino-esp32/blob/master/libraries/WebServer/examples/FSBrowser/FSBrowser.ino example should exhibit the bug. What I can say is: I have the code from PR #9167 running the last 3 days with zero issues. I uploaded many files (one with 1.6GB), and I tested excessively with Form data with nearly 100 postArgs. Rock solid for all my use cases with CORE 2.0.14 and 3.0.0 so far. |
I tried to reproduce this issue and wasn't able to trigger it. I tried to upload a text file with a SSL key using windows line endings with the FSBrowser example and I got no issues:
Do you have any idea of something else that might cause the behavior you are encountering ? |
Yes, because even though I tracked every upstream change to the WebServer library very closely, at least that's what I thought, I missed that one specific fix 3 and a half years ago: #4217 I'm sorry for that invalid bugreport. Nevertheless, I think my PR still has merit, because it reduces code size and improves readability, but that's of course subjective. Feel free to close the PR, if you don't feel like merging it on those grounds alone. BTW, I believe the WebServer lib could be improved further with not much effort. For example I saw that |
Board
n.a.
Device Description
n.a.
Hardware Configuration
n.a.
Version
latest master (checkout manually)
IDE Name
n.a.
Operating System
n.a.
Flash frequency
n.a.
PSRAM enabled
yes
Upload speed
n.a.
Description
When the file to upload ends with the string "--\r\n" (e.g. SSL cert files with windows line endings) the WebServer resets the connection before the upload is complete.
I guess the problem is somewhere here: https://github.com/espressif/arduino-esp32/blob/master/libraries/WebServer/src/Parsing.cpp#L353-L524
Sketch
Debug Message
Other Steps to Reproduce
n.a.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: