Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Fix macro invocation with post-increment index as argument #1125

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/WebRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@

static const String SharedEmptyString = String();

#define __is_param_char(c) ((c) && ((c) != '{') && ((c) != '[') && ((c) != '&') && ((c) != '='))
bool is_param_char(char c) {
return
(c != 0) &&
(c != '{') &&
(c != '[') &&
(c != '&') &&
(c != '=');
}

enum { PARSE_REQ_START, PARSE_REQ_HEADERS, PARSE_REQ_BODY, PARSE_REQ_END, PARSE_REQ_FAIL };

Expand Down Expand Up @@ -145,9 +152,9 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len){
if(_parsedLength == 0){
if(_contentType.startsWith("application/x-www-form-urlencoded")){
_isPlainPost = true;
} else if(_contentType == "text/plain" && __is_param_char(((char*)buf)[0])){
} else if(_contentType == "text/plain" && is_param_char(((char*)buf)[0])){
size_t i = 0;
while (i<len && __is_param_char(((char*)buf)[i++]));
while (i<len && is_param_char(((char*)buf)[i++]));
if(i < len && ((char*)buf)[i-1] == '='){
_isPlainPost = true;
}
Expand Down