-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Fix URL parameter decoding in web server #3313
Conversation
I think this has been fixed in #2956, please reopen if I'm wrong. |
Ok, rebased the test-related commits on top of master, and the tests fail. Haven't looked into the "why" yet, but i guess the fix which was merged was not comprehensive enough. |
@@ -317,8 +313,8 @@ void ESP8266WebServer::_parseArguments(String data) { | |||
continue; | |||
} | |||
RequestArgument& arg = _currentArgs[iarg]; | |||
arg.key = data.substring(pos, equal_sign_index); | |||
arg.value = data.substring(equal_sign_index + 1, next_arg_index); | |||
arg.key = urlDecode(data.substring(pos, equal_sign_index)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why decode the key as well, any use case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any case that uses non-URL-safe characters in key names is a use case for this. They need to be decoded as well as values.
The parameters string needs to be first split on & and =, and URL decoding on parts done after that. Otherwise URL encoded & and = within parameter names and values cause incorrect splitting.
The parameters string needs to be first split on
&
and=
, and URL decoding on parts done after that. Otherwise URL encoded&
and=
within parameter names and values cause incorrect splitting.I haven't been able to actually test this, except that it compiles. Running the test gives me a "begin timeout" for some reason before the test run starts. Compilation and upload appear to work fine.