aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-02-03 05:21:31 +0000
committerChristian Grothoff <christian@grothoff.org>2009-02-03 05:21:31 +0000
commit7c400e9e89cb344aac2ffa3a2b52e97b37f091ba (patch)
treefef3cac3440469010eb5bae27b79c9bbb37dd20f
parent6dbe4da5ed780b52914315945c6c73fa694d9d48 (diff)
downloadlibmicrohttpd-7c400e9e89cb344aac2ffa3a2b52e97b37f091ba.tar.gz
libmicrohttpd-7c400e9e89cb344aac2ffa3a2b52e97b37f091ba.zip
fixing 1447
-rw-r--r--src/daemon/internal.c42
-rw-r--r--src/daemon/internal.h5
-rw-r--r--src/daemon/postprocessor.c5
3 files changed, 36 insertions, 16 deletions
diff --git a/src/daemon/internal.c b/src/daemon/internal.c
index b4cabe68..fba19551 100644
--- a/src/daemon/internal.c
+++ b/src/daemon/internal.c
@@ -118,24 +118,42 @@ MHD_tls_log_func (int level, const char *str)
118/** 118/**
119 * Process escape sequences ('+'=space, %HH) 119 * Process escape sequences ('+'=space, %HH)
120 */ 120 */
121void 121unsigned int
122MHD_http_unescape (char *val) 122MHD_http_unescape (char *val)
123{ 123{
124 char *esc; 124 char *rpos = val;
125 char *wpos = val;
125 unsigned int num; 126 unsigned int num;
126 127
127 while (NULL != (esc = strstr (val, "+"))) 128 while ('\0' != *rpos)
128 *esc = ' ';
129 while (NULL != (esc = strstr (val, "%")))
130 { 129 {
131 if ((1 == SSCANF (&esc[1], 130 switch (*rpos)
132 "%2x", &num)) || (1 == SSCANF (&esc[1], "%2X", &num))) 131 {
133 { 132 case '+':
134 esc[0] = (unsigned char) num; 133 *wpos = ' ';
135 memmove (&esc[1], &esc[3], strlen (&esc[3]) + 1); 134 wpos++;
136 } 135 rpos++;
137 val = esc + 1; 136 break;
137 case '%':
138 if ( (1 == SSCANF (&rpos[1],
139 "%2x", &num)) ||
140 (1 == SSCANF (&rpos[1],
141 "%2X", &num)) )
142 {
143 *wpos = (unsigned char) num;
144 wpos++;
145 rpos += 3;
146 break;
147 }
148 /* intentional fall through! */
149 default:
150 *wpos = *rpos;
151 wpos++;
152 rpos++;
153 }
138 } 154 }
155 *wpos = '\0'; /* add 0-terminator */
156 return wpos - val; /* = strlen(val) */
139} 157}
140 158
141/* end of internal.c */ 159/* end of internal.c */
diff --git a/src/daemon/internal.h b/src/daemon/internal.h
index 969117fc..b257de2c 100644
--- a/src/daemon/internal.h
+++ b/src/daemon/internal.h
@@ -58,8 +58,11 @@ void MHD_tls_log_func (int level, const char *str);
58/** 58/**
59 * Process escape sequences ('+'=space, %HH). 59 * Process escape sequences ('+'=space, %HH).
60 * Updates val in place. 60 * Updates val in place.
61 *
62 * @return length of the resulting val (strlen(val) maybe
63 * shorter afterwards due to elimination of escape sequences)
61 */ 64 */
62void MHD_http_unescape (char *val); 65unsigned int MHD_http_unescape (char *val);
63 66
64/** 67/**
65 * Header or cookie in HTTP request or response. 68 * Header or cookie in HTTP request or response.
diff --git a/src/daemon/postprocessor.c b/src/daemon/postprocessor.c
index 3d25e4bd..60f09311 100644
--- a/src/daemon/postprocessor.c
+++ b/src/daemon/postprocessor.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman and Christian Grothoff 3 (C) 2007, 2009 Daniel Pittman and Christian Grothoff
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
@@ -403,8 +403,7 @@ post_process_urlencoded (struct MHD_PostProcessor *pp,
403 403
404 /* unescape */ 404 /* unescape */
405 xbuf[xoff] = '\0'; /* 0-terminate in preparation */ 405 xbuf[xoff] = '\0'; /* 0-terminate in preparation */
406 MHD_http_unescape (xbuf); 406 xoff = MHD_http_unescape (xbuf);
407
408 /* finally: call application! */ 407 /* finally: call application! */
409 if (MHD_NO == pp->ikvi (pp->cls, MHD_POSTDATA_KIND, (const char *) &pp[1], /* key */ 408 if (MHD_NO == pp->ikvi (pp->cls, MHD_POSTDATA_KIND, (const char *) &pp[1], /* key */
410 NULL, NULL, NULL, xbuf, pp->value_offset, 409 NULL, NULL, NULL, xbuf, pp->value_offset,