8000 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
fix pos substrings
key_end_pos--;
dont count down here, it will cut of every key by -1 ("save" will be "sav") (substring  (end = up to, but not including, so no need to -1)

Parsing cpp L329
arg.value = urlDecode(data.substring(equal_index + 1, next_index - 1));
=> -1 is too less for substring (substring  (end = up to, but not including, so no need to -1)
  • Loading branch information
reloxx13 authored Oct 13, 2018
commit 1ba0cfc758c35278e78ca59e21775522d7987e01
5 changes: 2 additions & 3 deletions libraries/ESP8266WebServer/src/Parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,16 @@ int ESP8266WebServer::_parseArgumentsPrivate(const String& data, int counted) {
key_end_pos = next_index;
if (key_end_pos == -1)
key_end_pos = data.length();
key_end_pos--;

// handle key/value
if (key_end_pos >= (int)pos) {
if ( (int)pos <= key_end_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, 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));
arg.value = urlDecode(data.substring(equal_index + 1, next_index));
#ifdef DEBUG_ESP_HTTP_SERVER
DEBUG_OUTPUT.print("arg ");
DEBUG_OUTPUT.print(arg_total);
Expand Down
0