浏览代码

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.
Ewan Mellor 11 年之前
父节点
当前提交
04f59a9214
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      GCDWebServer/Core/GCDWebServerFunctions.m

+ 3 - 2
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:@" "];