Description
Regardless of whether the body is set as plain or application/json, _parseArguments will always perform URL decoding on it, leading to unexpected results.
Example JSON sent:
{
"ssid" : "My+Network",
"psk" :"special+Password!"
}
After receiving it through ESP8266WebServer
{
"ssid" : "My Network",
"psk" :"special Password!"
}
Currently it makes it so no JSON can include a plus sign, or any other symbol the URL decoder will pick up.
EDIT: Incidentally, including something like this completely breaks input:
{ "ssid":"SSID+&(!@","psk":"@#$%^&+" }
Double EDIT:
A super simple if else block like this works around it for now:
if (data.indexOf(F("plain=")) != -1) {
_currentArgs = new RequestArgument[1];
RequestArgument& arg = _currentArgs[0];
arg.key = data.substring(data.indexOf(F("plain=")), data.indexOf(F("=")));
arg.value = data.substring(data.indexOf(F("=")) + 1);
} else {
I plan to modify it to include the option to retrieve the raw body payload if the content-type is equal to application/json, and not call _parseArguments. Would you be interested in this as a pull request once this is complete? I think this is the most sensible way to handle JSON data, otherwise it seems to be a bit of a hack to run it past something expecting url/form encoded data.