aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/microhttpd.h4
-rw-r--r--src/microhttpd/daemon.c20
-rw-r--r--src/microhttpd/internal.c34
3 files changed, 22 insertions, 36 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 2eb6e05c..67f26bc3 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -3300,8 +3300,8 @@ MHD_set_panic_func (MHD_PanicCallback cb, void *cls);
3300 3300
3301/** 3301/**
3302 * Process escape sequences ('%HH') Updates val in place; the 3302 * Process escape sequences ('%HH') Updates val in place; the
3303 * result should be UTF-8 encoded and cannot be larger than the input. 3303 * result cannot be larger than the input.
3304 * The result must also still be 0-terminated. 3304 * The result is still be 0-terminated.
3305 * 3305 *
3306 * @param val value to unescape (modified in the process) 3306 * @param val value to unescape (modified in the process)
3307 * @return length of the resulting val (`strlen(val)` may be 3307 * @return length of the resulting val (`strlen(val)` may be
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 8ba1baba..251e563e 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -45,6 +45,7 @@
45#include "mhd_compat.h" 45#include "mhd_compat.h"
46#include "mhd_send.h" 46#include "mhd_send.h"
47#include "mhd_align.h" 47#include "mhd_align.h"
48#include "mhd_str.h"
48 49
49#ifdef HAVE_SEARCH_H 50#ifdef HAVE_SEARCH_H
50#include <search.h> 51#include <search.h>
@@ -5672,7 +5673,7 @@ MHD_polling_thread (void *cls)
5672 5673
5673/** 5674/**
5674 * Process escape sequences ('%HH') Updates val in place; the 5675 * Process escape sequences ('%HH') Updates val in place; the
5675 * result should be UTF-8 encoded and cannot be larger than the input. 5676 * result cannot be larger than the input.
5676 * The result must also still be 0-terminated. 5677 * The result must also still be 0-terminated.
5677 * 5678 *
5678 * @param cls closure (use NULL) 5679 * @param cls closure (use NULL)
@@ -5686,10 +5687,23 @@ unescape_wrapper (void *cls,
5686 struct MHD_Connection *connection, 5687 struct MHD_Connection *connection,
5687 char *val) 5688 char *val)
5688{ 5689{
5690 bool broken;
5691 size_t res;
5689 (void) cls; /* Mute compiler warning. */ 5692 (void) cls; /* Mute compiler warning. */
5690 5693
5691 (void) connection; /* Mute compiler warning. */ 5694 /* TODO: add individual parameter */
5692 return MHD_http_unescape (val); 5695 if (1 <= connection->daemon->strict_for_client)
5696 return MHD_str_pct_decode_in_place_strict_ (val);
5697
5698 res = MHD_str_pct_decode_in_place_lenient_ (val, &broken);
5699#ifdef HAVE_MESSAGES
5700 if (broken)
5701 {
5702 MHD_DLOG (connection->daemon,
5703 _ ("The URL encoding is broken.\n"));
5704 }
5705#endif /* HAVE_MESSAGES */
5706 return res;
5693} 5707}
5694 5708
5695 5709
diff --git a/src/microhttpd/internal.c b/src/microhttpd/internal.c
index e9e92414..57553251 100644
--- a/src/microhttpd/internal.c
+++ b/src/microhttpd/internal.c
@@ -135,8 +135,8 @@ MHD_unescape_plus (char *arg)
135 135
136/** 136/**
137 * Process escape sequences ('%HH') Updates val in place; the 137 * Process escape sequences ('%HH') Updates val in place; the
138 * result should be UTF-8 encoded and cannot be larger than the input. 138 * result cannot be larger than the input.
139 * The result must also still be 0-terminated. 139 * The result is still be 0-terminated.
140 * 140 *
141 * @param val value to unescape (modified in the process) 141 * @param val value to unescape (modified in the process)
142 * @return length of the resulting val (`strlen(val)` may be 142 * @return length of the resulting val (`strlen(val)` may be
@@ -145,35 +145,7 @@ MHD_unescape_plus (char *arg)
145_MHD_EXTERN size_t 145_MHD_EXTERN size_t
146MHD_http_unescape (char *val) 146MHD_http_unescape (char *val)
147{ 147{
148 char *rpos = val; 148 return MHD_str_pct_decode_in_place_lenient_ (val, NULL);
149 char *wpos = val;
150
151 while ('\0' != *rpos)
152 {
153 uint32_t num;
154 switch (*rpos)
155 {
156 case '%':
157 if (2 == MHD_strx_to_uint32_n_ (rpos + 1,
158 2,
159 &num))
160 {
161 *wpos = (char) ((unsigned char) num);
162 wpos++;
163 rpos += 3;
164 break;
165 }
166 /* TODO: add bad sequence handling */
167 /* intentional fall through! */
168 default:
169 *wpos = *rpos;
170 wpos++;
171 rpos++;
172 }
173 }
174 *wpos = '\0'; /* add 0-terminator */
175 mhd_assert (wpos >= val);
176 return (size_t) (wpos - val);
177} 149}
178 150
179 151