Christian Grothoff 13 lat temu
rodzic
commit
fe480ef1ad
3 zmienionych plików z 18 dodań i 5 usunięć
  1. 5 0
      ChangeLog
  2. 7 0
      src/daemon/postprocessor.c
  3. 6 5
      src/daemon/postprocessor_test.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Fri Feb  1 10:19:44 CET 2013
+	Handle case where POST data contains "key=" without value
+	at the end and is not new-line terminated by invoking the
+	callback with the "key" during MHD_destroy_post_processor (#2733). -CG
+
 Wed Jan 30 13:09:30 CET 2013
 	Adding more 'const' to allow keeping of reason phrases in ROM.
 	(see mailinglist). -CG/MV

+ 7 - 0
src/daemon/postprocessor.c

@@ -1062,6 +1062,13 @@ MHD_destroy_post_processor (struct MHD_PostProcessor *pp)
 
   if (NULL == pp)
     return MHD_YES;
+  if (PP_ProcessValue == pp->state)
+  {
+    /* key without terminated value left at the end of the
+       buffer; fake receiving a termination character to
+       ensure it is also processed */
+    post_process_urlencoded (pp, "\n", 1);
+  }
   /* These internal strings need cleaning up since
      the post-processing may have been interrupted
      at any stage */

+ 6 - 5
src/daemon/postprocessor_test.c

@@ -60,11 +60,12 @@ const char *want[] = {
   "pics", "file2.gif", "image/gif", "binary", "filedata2",
 #define FORM_NESTED_END (FORM_NESTED_START + 15)
   NULL, NULL, NULL, NULL, NULL,
-#define URL_EMPTY_VALUE_DATA "key1=value1&key2="
+#define URL_EMPTY_VALUE_DATA "key1=value1&key2=&key3="
 #define URL_EMPTY_VALUE_START (FORM_NESTED_END + 5)
   "key1", NULL, NULL, NULL, "value1",
-  "key2", NULL, NULL, NULL, NULL,
-#define URL_EMPTY_VALUE_END (URL_EMPTY_VALUE_START + 10)
+  "key2", NULL, NULL, NULL, "",
+  "key3", NULL, NULL, NULL, "",
+#define URL_EMPTY_VALUE_END (URL_EMPTY_VALUE_START + 15)
   NULL, NULL, NULL, NULL, NULL
 };
 
@@ -95,8 +96,8 @@ value_checker (void *cls,
            "VC: `%s' `%s' `%s' `%s' `%.*s'\n",
            key, filename, content_type, transfer_encoding, size, data);
 #endif
-  if (size == 0)
-    return MHD_YES;
+  if ( (0 != off) && (0 == size) )
+    return MHD_YES; 
   if ((idx < 0) ||
       (want[idx] == NULL) ||
       (0 != strcmp (key, want[idx])) ||