From b3b723b4531a3781ab847a2652cf192303e78941 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 25 Dec 2016 18:29:21 +0100 Subject: Refactored to put URL Encoding / Decoding in a single place. (#3491) --- src/HTTP/HTTPFormParser.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/HTTP/HTTPFormParser.cpp') diff --git a/src/HTTP/HTTPFormParser.cpp b/src/HTTP/HTTPFormParser.cpp index ea5da3c18..6ad5d2592 100644 --- a/src/HTTP/HTTPFormParser.cpp +++ b/src/HTTP/HTTPFormParser.cpp @@ -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; } } -- cgit v1.2.3