From 04f59a9214e97a5076e04b61d625d8d157ce7793 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Wed, 30 Apr 2014 17:08:42 -0700 Subject: [PATCH] Fix GCDWebServerParseURLEncodedForm to allow empty values. If the input string is something like foo=&bar= then both foo and bar should be in the result, with the empty string as their corresponding value. The [scanner scanUpToString:@"&" ...] call was returning failure, because it was already positioned at the &. In this situation, just set value to the empty string. --- GCDWebServer/Core/GCDWebServerFunctions.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GCDWebServer/Core/GCDWebServerFunctions.m b/GCDWebServer/Core/GCDWebServerFunctions.m index ba82264..25f47ac 100644 --- a/GCDWebServer/Core/GCDWebServerFunctions.m +++ b/GCDWebServer/Core/GCDWebServerFunctions.m @@ -198,8 +198,9 @@ NSDictionary* GCDWebServerParseURLEncodedForm(NSString* form) { [scanner setScanLocation:([scanner scanLocation] + 1)]; NSString* value = nil; - if (![scanner scanUpToString:@"&" intoString:&value]) { - break; + [scanner scanUpToString:@"&" intoString:&value]; + if (value == nil) { + value = @""; } key = [key stringByReplacingOccurrencesOfString:@"+" withString:@" "];