Skip to content

Commit 3c30798

Browse files
fix(webserver): Ignore extra headers within multipart forms (#9253)
Update subpart ("PostArg") parsing to ignore extra headers instead of silently failing. Co-authored-by: Lucas Saavedra Vaz <[email protected]>
1 parent bc769fd commit 3c30798

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: libraries/WebServer/src/Parsing.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,12 @@ bool WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t len){
368368
argType = FPSTR(mimeTable[txt].mimeType);
369369
line = client.readStringUntil('\r');
370370
client.readStringUntil('\n');
371-
if (line.length() > 12 && line.substring(0, 12).equalsIgnoreCase(FPSTR(Content_Type))){
372-
argType = line.substring(line.indexOf(':')+2);
373-
//skip next line
374-
client.readStringUntil('\r');
371+
while (line.length() > 0) {
372+
if (line.length() > 12 && line.substring(0, 12).equalsIgnoreCase(FPSTR(Content_Type))){
373+
argType = line.substring(line.indexOf(':')+2);
374+
}
375+
//skip over any other headers
376+
line = client.readStringUntil('\r');
375377
client.readStringUntil('\n');
376378
}
377379
log_v("PostArg Type: %s", argType.c_str());

0 commit comments

Comments
 (0)