commit fe480ef1ad1befbb1582d48dacd69e9f635ffc10
parent 08ce8b39168a9272276d0c50340998a64f06b4cc
Author: Christian Grothoff <christian@grothoff.org>
Date: Fri, 1 Feb 2013 09:20:40 +0000
fix #2733
Diffstat:
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/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
diff --git a/src/daemon/postprocessor.c b/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 */
diff --git a/src/daemon/postprocessor_test.c b/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])) ||