570c254e1633c283bc47f651ca984d4d69b7c1f7
[project/luci.git] / libs / sgi-webuci / boa-patches / 060-buffer_escape.patch
1 diff --git a/src/buffer.c b/src/buffer.c
2 index 99f3e7c..6720e21 100644
3 --- a/src/buffer.c
4 +++ b/src/buffer.c
5 @@ -77,6 +77,7 @@ int req_write_escape_http(request * req, const char *msg)
6 char c, *dest;
7 const char *inp;
8
9 + int skip = 0;
10 int left;
11 inp = msg;
12 dest = req->buffer + req->buffer_end;
13 @@ -84,7 +85,12 @@ int req_write_escape_http(request * req, const char *msg)
14 * in the middle of a transfer of up to 3 bytes */
15 left = BUFFER_SIZE - req->buffer_end;
16 while ((c = *inp++) && left >= 3) {
17 - if (needs_escape((unsigned int) c)) {
18 + /* Lower the skip character count. */
19 + if (skip) skip--;
20 + /* If we have a '%', we skip the two follow characters. */
21 + if (c == '%') skip = 2;
22 +
23 + if (!skip && needs_escape((unsigned int) c)) {
24 *dest++ = '%';
25 *dest++ = INT_TO_HEX((c >> 4) & 0xf);
26 *dest++ = INT_TO_HEX(c & 0xf);