Fix POST processing of final keys without values for libhttpserver

This patch fixes the processing of POST parameters for content type
'application/x-www-form-urlencoded'. Prior to this patch if a final key
is present in the params without a value, it's left unprocessed.
pull/3874/head
Javier Jaramago Fernández 4 years ago
parent 28cb149887
commit b25a0ca381

1
deps/Makefile vendored

@ -87,6 +87,7 @@ ifeq ($(REQUIRE_PATCH), true)
cd libhttpserver/libhttpserver && patch src/httpserver/http_response.hpp < ../http_response.hpp.patch
cd libhttpserver/libhttpserver && patch src/httpserver/string_response.hpp < ../string_response.hpp.patch
cd libhttpserver/libhttpserver && patch -p0 < ../re2_regex.patch
cd libhttpserver/libhttpserver && patch -p0 < ../final_val_post_process.patch
endif
ifeq ($(UNAME_S),FreeBSD)
sed -i -e 's/\/bin\/bash/\/usr\/local\/bin\/bash/' libhttpserver/libhttpserver/bootstrap

@ -0,0 +1,19 @@
diff --git src/webserver.cpp src/webserver.cpp
index a3104e9..5ae7381 100644
--- src/webserver.cpp
+++ src/webserver.cpp
@@ -676,6 +676,14 @@ int webserver::finalize_answer(
{
if(hrm->is_allowed(method))
{
+ // NOTE: Here 'MHD_destroy_post_processor' is required for performing a final 'post_process'
+ // of the 'URL Encode'. This ensures ensures the processing of final key without value left
+ // at the end of the buffer. See function internal doc at 'postprocessor.c'.
+ if (mr->pp != NULL) {
+ MHD_destroy_post_processor(mr->pp);
+ mr->pp = NULL;
+ }
+
mr->dhrs = ((hrm)->*(mr->callback))(*mr->dhr); //copy in memory (move in case)
if (mr->dhrs->get_response_code() == -1)
{
Loading…
Cancel
Save