mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Remove trailing tabs in HTTP headers as well.
This commit is contained in:
parent
aa59d805f5
commit
ac42519769
6
http.c
6
http.c
@ -220,7 +220,7 @@ strsep(char **s, const char *del)
|
||||
#endif
|
||||
|
||||
void
|
||||
evutil_rtrim_(char *str)
|
||||
evutil_rtrim_lws_(char *str)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
@ -232,7 +232,7 @@ evutil_rtrim_(char *str)
|
||||
|
||||
--cp;
|
||||
|
||||
while (*cp == ' ') {
|
||||
while (*cp == ' ' || *cp == '\t') {
|
||||
*cp = '\0';
|
||||
if (cp == str)
|
||||
break;
|
||||
@ -1934,7 +1934,7 @@ evhttp_parse_headers_(struct evhttp_request *req, struct evbuffer* buffer)
|
||||
goto error;
|
||||
|
||||
svalue += strspn(svalue, " ");
|
||||
evutil_rtrim_(svalue);
|
||||
evutil_rtrim_lws_(svalue);
|
||||
|
||||
if (evhttp_add_header(headers, skey, svalue) == -1)
|
||||
goto error;
|
||||
|
@ -441,7 +441,7 @@ test_evutil_rtrim(void *ptr)
|
||||
do { \
|
||||
if (cp) mm_free(cp); \
|
||||
cp = s ? mm_strdup(s) : NULL; \
|
||||
evutil_rtrim_(cp); \
|
||||
evutil_rtrim_lws_(cp); \
|
||||
if (result == NULL) \
|
||||
tt_ptr_op(cp, ==, NULL); \
|
||||
else \
|
||||
@ -461,6 +461,14 @@ test_evutil_rtrim(void *ptr)
|
||||
TEST_TRIM("a ", "a");
|
||||
TEST_TRIM("abcdef gH ", "abcdef gH");
|
||||
|
||||
TEST_TRIM("\t\t", "");
|
||||
TEST_TRIM(" \t", "");
|
||||
TEST_TRIM("\t", "");
|
||||
TEST_TRIM("a \t", "a");
|
||||
TEST_TRIM("a\t ", "a");
|
||||
TEST_TRIM("a\t", "a");
|
||||
TEST_TRIM("abcdef gH \t ", "abcdef gH");
|
||||
|
||||
end:
|
||||
if (cp)
|
||||
mm_free(cp);
|
||||
|
@ -218,8 +218,9 @@ int EVUTIL_ISUPPER_(char c);
|
||||
char EVUTIL_TOUPPER_(char c);
|
||||
char EVUTIL_TOLOWER_(char c);
|
||||
|
||||
/** Remove all trailing whitespace from the end of a string */
|
||||
void evutil_rtrim_(char *);
|
||||
/** Remove all trailing horizontal whitespace (space or tab) from the end of a
|
||||
* string */
|
||||
void evutil_rtrim_lws_(char *);
|
||||
|
||||
|
||||
/** Helper macro. If we know that a given pointer points to a field in a
|
||||
|
Loading…
x
Reference in New Issue
Block a user