HTTP parser: allowing tabs in field values as per RFC 7230.
This commit is contained in:
@@ -629,6 +629,7 @@ nxt_http_parse_field_value(nxt_http_request_parse_t *rp, u_char **pos,
|
|||||||
|
|
||||||
p += rp->field_value.length;
|
p += rp->field_value.length;
|
||||||
|
|
||||||
|
for ( ;; ) {
|
||||||
p = nxt_http_lookup_field_end(p, end);
|
p = nxt_http_lookup_field_end(p, end);
|
||||||
|
|
||||||
if (nxt_slow_path(p == end)) {
|
if (nxt_slow_path(p == end)) {
|
||||||
@@ -647,10 +648,17 @@ nxt_http_parse_field_value(nxt_http_request_parse_t *rp, u_char **pos,
|
|||||||
|
|
||||||
ch = *p;
|
ch = *p;
|
||||||
|
|
||||||
if (nxt_slow_path(ch != '\r' && ch != '\n')) {
|
if (nxt_fast_path(ch == '\r' || ch == '\n')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch != '\t') {
|
||||||
return NXT_HTTP_PARSE_INVALID;
|
return NXT_HTTP_PARSE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
*pos = p;
|
*pos = p;
|
||||||
|
|
||||||
if (nxt_fast_path(p != start)) {
|
if (nxt_fast_path(p != start)) {
|
||||||
|
|||||||
@@ -268,6 +268,18 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
|
|||||||
NXT_HTTP_PARSE_INVALID,
|
NXT_HTTP_PARSE_INVALID,
|
||||||
NULL, { NULL }
|
NULL, { NULL }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
nxt_string("GET / HTTP/1.1\r\n"
|
||||||
|
"Ho\nst: example.com\r\n\r\n"),
|
||||||
|
NXT_HTTP_PARSE_INVALID,
|
||||||
|
NULL, { NULL }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
nxt_string("GET / HTTP/1.1\r\n"
|
||||||
|
"Host : example.com\r\n\r\n"),
|
||||||
|
NXT_HTTP_PARSE_INVALID,
|
||||||
|
NULL, { NULL }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
nxt_string("GET / HTTP/1.1\r\n"
|
nxt_string("GET / HTTP/1.1\r\n"
|
||||||
"Host: exa\0mple.com\r\n\r\n"),
|
"Host: exa\0mple.com\r\n\r\n"),
|
||||||
@@ -298,6 +310,18 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
|
|||||||
NXT_DONE,
|
NXT_DONE,
|
||||||
NULL, { NULL }
|
NULL, { NULL }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
nxt_string("GET / HTTP/1.1\r\n"
|
||||||
|
"Host: exa\nmple.com\r\n\r\n"),
|
||||||
|
NXT_HTTP_PARSE_INVALID,
|
||||||
|
NULL, { NULL }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
nxt_string("GET / HTTP/1.1\r\n"
|
||||||
|
"Host: exa\tmple.com\r\n\r\n"),
|
||||||
|
NXT_DONE,
|
||||||
|
NULL, { NULL }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
nxt_string("GET / HTTP/1.1\r\n"
|
nxt_string("GET / HTTP/1.1\r\n"
|
||||||
"X-Unknown-Header: value\r\n"
|
"X-Unknown-Header: value\r\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user