Skip to content

Commit 2355e5f

Browse files
authored
Merge branch 'master' into armv8-a
2 parents c04a8f7 + 81fe3d9 commit 2355e5f

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

picohttpparser.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
#endif
4040
#include "picohttpparser.h"
4141

42-
/* $Id$ */
43-
4442
#if __GNUC__ >= 3
4543
#define likely(x) __builtin_expect(!!(x), 1)
4644
#define unlikely(x) __builtin_expect(!!(x), 0)
@@ -169,9 +167,9 @@ static const char *findchar_nonprintable_fast(const char *buf, const char *buf_e
169167

170168
return buf;
171169
#else
172-
static const char ALIGNED(16) ranges2[] = "\000\040\177\177";
170+
static const char ALIGNED(16) ranges2[16] = "\000\040\177\177";
173171

174-
return findchar_fast(buf, buf_end, ranges2, sizeof(ranges2) - 1, found);
172+
return findchar_fast(buf, buf_end, ranges2, 4, found);
175173
#endif
176174
}
177175

@@ -180,15 +178,11 @@ static const char *get_token_to_eol(const char *buf, const char *buf_end, const
180178
const char *token_start = buf;
181179

182180
#ifdef __SSE4_2__
183-
static const char ranges1[] = "\0\010"
184-
/* allow HT */
185-
"\012\037"
186-
/* allow SP and up to but not including DEL */
187-
"\177\177"
188-
/* allow chars w. MSB set */
189-
;
181+
static const char ALIGNED(16) ranges1[16] = "\0\010" /* allow HT */
182+
"\012\037" /* allow SP and up to but not including DEL */
183+
"\177\177"; /* allow chars w. MSB set */
190184
int found;
191-
buf = findchar_fast(buf, buf_end, ranges1, sizeof(ranges1) - 1, &found);
185+
buf = findchar_fast(buf, buf_end, ranges1, 6, &found);
192186
if (found)
193187
goto FOUND_CTL;
194188
#elif defined(__ARM_64BIT_STATE) && defined(__ARM_FEATURE_UNALIGNED) && !defined(__ARM_BIG_ENDIAN)
@@ -433,9 +427,13 @@ static const char *parse_request(const char *buf, const char *buf_end, const cha
433427

434428
/* parse request line */
435429
ADVANCE_TOKEN(*method, *method_len);
436-
++buf;
430+
do {
431+
++buf;
432+
} while (*buf == ' ');
437433
ADVANCE_TOKEN(*path, *path_len);
438-
++buf;
434+
do {
435+
++buf;
436+
} while (*buf == ' ');
439437
if (*method_len == 0 || *path_len == 0) {
440438
*ret = -1;
441439
return NULL;
@@ -492,10 +490,13 @@ static const char *parse_response(const char *buf, const char *buf_end, int *min
492490
return NULL;
493491
}
494492
/* skip space */
495-
if (*buf++ != ' ') {
493+
if (*buf != ' ') {
496494
*ret = -1;
497495
return NULL;
498496
}
497+
do {
498+
++buf;
499+
} while (*buf == ' ');
499500
/* parse status code, we want at least [:digit:][:digit:][:digit:]<other char> to try to parse */
500501
if (buf_end - buf < 4) {
501502
*ret = -2;
@@ -511,8 +512,10 @@ static const char *parse_response(const char *buf, const char *buf_end, int *min
511512
/* ok */
512513
} else if (**msg == ' ') {
513514
/* remove preceding space */
514-
++*msg;
515-
--*msg_len;
515+
do {
516+
++*msg;
517+
--*msg_len;
518+
} while (**msg == ' ');
516519
} else {
517520
/* garbage found after status code */
518521
*ret = -1;

picohttpparser.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#define ssize_t intptr_t
3434
#endif
3535

36-
/* $Id$ */
37-
3836
#ifdef __cplusplus
3937
extern "C" {
4038
#endif

test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ static void test_request(void)
146146
PARSE("GET / HTTP/1.0\r\nfoo: a \t \r\n\r\n", 0, 0, "exclude leading and trailing spaces in header value");
147147
ok(bufis(headers[0].value, headers[0].value_len, "a"));
148148

149+
PARSE("GET / HTTP/1.0\r\n\r\n", 0, 0, "accept multiple spaces between tokens");
150+
149151
#undef PARSE
150152
}
151153

@@ -245,6 +247,8 @@ static void test_response(void)
245247
PARSE("HTTP/1.1 200 OK\r\nbar: \t b\t \t\r\n\r\n", 0, 0, "exclude leading and trailing spaces in header value");
246248
ok(bufis(headers[0].value, headers[0].value_len, "b"));
247249

250+
PARSE("HTTP/1.1 200 OK\r\n\r\n", 0, 0, "accept multiple spaces between tokens");
251+
248252
#undef PARSE
249253
}
250254

0 commit comments

Comments
 (0)