10000 fix parseArgument by d-a-v · Pull Request #5230 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

fix parseArgument #5230

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

Closed
wants to merge 16 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
keep variable naming style consistent
  • Loading branch information
d-a-v committed Oct 11, 2018
commit db0cd7d789687184880a745e1df4f70e1838a2ff
16 changes: 8 additions & 8 deletions libraries/ESP8266WebServer/src/Parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,24 +305,24 @@ int ESP8266WebServer::_parseArgumentsPrivate(const String& data, int counted) {

// locate separators
int equal_index = data.indexOf('=', pos);
int keyEndPos = equal_index;
int key_end_pos = equal_index;
int next_index = data.indexOf('&', pos);
int next_index2 = data.indexOf(';', pos);
if ((next_index == -1) || (next_index2 != -1 && next_index2 < next_index))
next_index = next_index2;
if ((keyEndPos == -1) || ((keyEndPos > next_index) && (next_index != -1)))
keyEndPos = next_index;
if (keyEndPos == -1)
keyEndPos = data.length();
keyEndPos--;
if ((key_end_pos == -1) || ((key_end_pos > next_index) && (next_index != -1)))
key_end_pos = next_index;
if (key_end_pos == -1)
key_end_pos = data.length();
key_end_pos--;

// handle key/value
if (keyEndPos >= (int)pos) {
if (key_end_pos >= (int)pos) {
// do not store or count empty ending key ("url?x=y;")

if (counted > 0) {
RequestArgument& arg = _currentArgs[arg_total];
arg.key = urlDecode(data.substring(pos, keyEndPos));
arg.key = urlDecode(data.substring(pos, key_end_pos));
if ((equal_index != -1) && ((equal_index < next_index - 1) || (next_index == -1)))
arg.value = urlDecode(data.substring(equal_index + 1, next_index - 1));
#ifdef DEBUG_ESP_HTTP_SERVER
Expand Down
0