Skip to content

Commit

Permalink
fix(webserver): Ignore extra headers within multipart forms (#9253)
Browse files Browse the repository at this point in the history
Update subpart ("PostArg") parsing to ignore extra headers instead of silently failing.

Co-authored-by: Lucas Saavedra Vaz <[email protected]>
  • Loading branch information
tcsullivan and lucasssvaz authored Feb 20, 2024
1 parent bc769fd commit 3c30798
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libraries/WebServer/src/Parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,12 @@ bool WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t len){
argType = FPSTR(mimeTable[txt].mimeType);
line = client.readStringUntil('\r');
client.readStringUntil('\n');
if (line.length() > 12 && line.substring(0, 12).equalsIgnoreCase(FPSTR(Content_Type))){
argType = line.substring(line.indexOf(':')+2);
//skip next line
client.readStringUntil('\r');
while (line.length() > 0) {
if (line.length() > 12 && line.substring(0, 12).equalsIgnoreCase(FPSTR(Content_Type))){
argType = line.substring(line.indexOf(':')+2);
}
//skip over any other headers
line = client.readStringUntil('\r');
client.readStringUntil('\n');
}
log_v("PostArg Type: %s", argType.c_str());
Expand Down

0 comments on commit 3c30798

Please sign in to comment.