mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
Merge pull request #1069 from joostjager/master
Url decode added for search parameters
This commit is contained in:
commit
14bd3d9ff2
@ -133,6 +133,7 @@ protected:
|
|||||||
uint8_t _uploadReadByte(WiFiClient& client);
|
uint8_t _uploadReadByte(WiFiClient& client);
|
||||||
void _prepareHeader(String& response, int code, const char* content_type, size_t contentLength);
|
void _prepareHeader(String& response, int code, const char* content_type, size_t contentLength);
|
||||||
bool _collectHeader(const char* headerName, const char* headerValue);
|
bool _collectHeader(const char* headerName, const char* headerValue);
|
||||||
|
String urlDecode(const String& text);
|
||||||
|
|
||||||
struct RequestArgument {
|
struct RequestArgument {
|
||||||
String key;
|
String key;
|
||||||
|
@ -263,7 +263,7 @@ void ESP8266WebServer::_parseArguments(String data) {
|
|||||||
}
|
}
|
||||||
RequestArgument& arg = _currentArgs[iarg];
|
RequestArgument& arg = _currentArgs[iarg];
|
||||||
arg.key = data.substring(pos, equal_sign_index);
|
arg.key = data.substring(pos, equal_sign_index);
|
||||||
arg.value = data.substring(equal_sign_index + 1, next_arg_index);
|
arg.value = urlDecode(data.substring(equal_sign_index + 1, next_arg_index));
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
DEBUG_OUTPUT.print("arg ");
|
DEBUG_OUTPUT.print("arg ");
|
||||||
DEBUG_OUTPUT.print(iarg);
|
DEBUG_OUTPUT.print(iarg);
|
||||||
@ -513,6 +513,37 @@ readfile:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ESP8266WebServer::urlDecode(const String& text)
|
||||||
|
{
|
||||||
|
String decoded = "";
|
||||||
|
char temp[] = "0x00";
|
||||||
|
unsigned int len = text.length();
|
||||||
|
unsigned int i = 0;
|
||||||
|
while (i < len)
|
||||||
|
{
|
||||||
|
char decodedChar;
|
||||||
|
char encodedChar = text.charAt(i++);
|
||||||
|
if ((encodedChar == '%') && (i + 1 < len))
|
||||||
|
{
|
||||||
|
temp[2] = text.charAt(i++);
|
||||||
|
temp[3] = text.charAt(i++);
|
||||||
|
|
||||||
|
decodedChar = strtol(temp, NULL, 16);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (encodedChar == '+')
|
||||||
|
{
|
||||||
|
decodedChar = ' ';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
decodedChar = encodedChar; // normal ascii char
|
||||||
|
}
|
||||||
|
}
|
||||||
|
decoded += decodedChar;
|
||||||
|
}
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
bool ESP8266WebServer::_parseFormUploadAborted(){
|
bool ESP8266WebServer::_parseFormUploadAborted(){
|
||||||
_currentUpload.status = UPLOAD_FILE_ABORTED;
|
_currentUpload.status = UPLOAD_FILE_ABORTED;
|
||||||
if(_currentHandler && _currentHandler->canUpload(_currentUri))
|
if(_currentHandler && _currentHandler->canUpload(_currentUri))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user