-
-
Notifications
You must be signed in to change notification settings - Fork 494
Fix for multipart form data without trailing CRLF #1048
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
base: master
Are you sure you want to change the base?
Conversation
…hout trailing CRLF as allowed by RFC 2046.
Cleaned up and commented code. Moved final_delim declaration outside loop and updated while loop condition to check state of final_delim instead.
Commit fixes #1040 |
{ | ||
std::string delimiter = dd + boundary; | ||
std::string normal_delim = dd + boundary; | ||
std::string final_delim = normal_delim + dd; // Create final delimiter to check against |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these strings are const or constexpr
if (found == std::string::npos) | ||
// Find next regular and final delimiter | ||
size_t next_normal = body.find(normal_delim); | ||
size_t next_final = body.find(final_delim); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not very effective as next_final is always one position after next_normal or not found.
So it should be sufficient to check for dd after the normal delimiter instead of do a find again over the complete string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See code comments on algorithm
Modified parse_body in multipart.h to support multipart form data without trailing CRLF as allowed by RFC 2046.