1
0

Refactored to put URL Encoding / Decoding in a single place. (#3491)

This commit is contained in:
Mattes D
2016-12-25 18:29:21 +01:00
committed by GitHub
parent efc7fed05b
commit b3b723b453
7 changed files with 297 additions and 106 deletions

View File

@@ -167,13 +167,22 @@ void cHTTPFormParser::ParseFormUrlEncoded(void)
case 1:
{
// Only name present
(*this)[URLDecode(ReplaceAllCharOccurrences(Components[0], '+', ' '))] = "";
auto name = URLDecode(ReplaceAllCharOccurrences(Components[0], '+', ' '));
if (name.first)
{
(*this)[name.second] = "";
}
break;
}
case 2:
{
// name=value format:
(*this)[URLDecode(ReplaceAllCharOccurrences(Components[0], '+', ' '))] = URLDecode(ReplaceAllCharOccurrences(Components[1], '+', ' '));
auto name = URLDecode(Components[0]);
auto value = URLDecode(Components[1]);
if (name.first && value.first)
{
(*this)[name.second] = value.second;
}
break;
}
}