summaryrefslogtreecommitdiff
path: root/sapi/cli/php_http_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/cli/php_http_parser.c')
-rw-r--r--sapi/cli/php_http_parser.c85
1 files changed, 11 insertions, 74 deletions
diff --git a/sapi/cli/php_http_parser.c b/sapi/cli/php_http_parser.c
index 71730322e0..82c74e93c2 100644
--- a/sapi/cli/php_http_parser.c
+++ b/sapi/cli/php_http_parser.c
@@ -92,6 +92,7 @@ static const char *method_strings[] =
, "MKCALENDAR"
, "PROPFIND"
, "PROPPATCH"
+ , "SEARCH"
, "UNLOCK"
, "REPORT"
, "MKACTIVITY"
@@ -194,75 +195,6 @@ static const uint8_t normal_url_char[256] = {
1, 1, 1, 1, 1, 1, 1, 0 };
-enum state
- { s_dead = 1 /* important that this is > 0 */
-
- , s_start_req_or_res
- , s_res_or_resp_H
- , s_start_res
- , s_res_H
- , s_res_HT
- , s_res_HTT
- , s_res_HTTP
- , s_res_first_http_major
- , s_res_http_major
- , s_res_first_http_minor
- , s_res_http_minor
- , s_res_first_status_code
- , s_res_status_code
- , s_res_status
- , s_res_line_almost_done
-
- , s_start_req
-
- , s_req_method
- , s_req_spaces_before_url
- , s_req_schema
- , s_req_schema_slash
- , s_req_schema_slash_slash
- , s_req_host
- , s_req_port
- , s_req_path
- , s_req_query_string_start
- , s_req_query_string
- , s_req_fragment_start
- , s_req_fragment
- , s_req_http_start
- , s_req_http_H
- , s_req_http_HT
- , s_req_http_HTT
- , s_req_http_HTTP
- , s_req_first_http_major
- , s_req_http_major
- , s_req_first_http_minor
- , s_req_http_minor
- , s_req_line_almost_done
-
- , s_header_field_start
- , s_header_field
- , s_header_value_start
- , s_header_value
-
- , s_header_almost_done
-
- , s_headers_almost_done
- /* Important: 's_headers_almost_done' must be the last 'header' state. All
- * states beyond this must be 'body' states. It is used for overflow
- * checking. See the PARSING_HEADER() macro.
- */
- , s_chunk_size_start
- , s_chunk_size
- , s_chunk_size_almost_done
- , s_chunk_parameters
- , s_chunk_data
- , s_chunk_data_almost_done
- , s_chunk_data_done
-
- , s_body_identity
- , s_body_identity_eof
- };
-
-
#define PARSING_HEADER(state) (state <= s_headers_almost_done && 0 == (parser->flags & F_TRAILING))
@@ -326,7 +258,8 @@ size_t php_http_parser_execute (php_http_parser *parser,
const char *data,
size_t len)
{
- char c, ch;
+ char ch;
+ signed char c;
const char *p = data, *pe;
size_t to_read;
@@ -589,7 +522,7 @@ size_t php_http_parser_execute (php_http_parser *parser,
case 'O': parser->method = PHP_HTTP_OPTIONS; break;
case 'P': parser->method = PHP_HTTP_POST; /* or PROPFIND or PROPPATCH or PUT */ break;
case 'R': parser->method = PHP_HTTP_REPORT; break;
- case 'S': parser->method = PHP_HTTP_SUBSCRIBE; break;
+ case 'S': parser->method = PHP_HTTP_SUBSCRIBE; /* or SEARCH */ break;
case 'T': parser->method = PHP_HTTP_TRACE; break;
case 'U': parser->method = PHP_HTTP_UNLOCK; /* or UNSUBSCRIBE */ break;
default: parser->method = PHP_HTTP_NOT_IMPLEMENTED; break;
@@ -597,7 +530,6 @@ size_t php_http_parser_execute (php_http_parser *parser,
state = s_req_method;
break;
}
-
case s_req_method:
{
const char *matcher;
@@ -640,6 +572,8 @@ size_t php_http_parser_execute (php_http_parser *parser,
parser->method = PHP_HTTP_PUT;
} else if (index == 1 && parser->method == PHP_HTTP_POST && ch == 'A') {
parser->method = PHP_HTTP_PATCH;
+ } else if (index == 1 && parser->method == PHP_HTTP_SUBSCRIBE && ch == 'E') {
+ parser->method = PHP_HTTP_SEARCH;
} else if (index == 2 && parser->method == PHP_HTTP_UNLOCK && ch == 'S') {
parser->method = PHP_HTTP_UNSUBSCRIBE;
} else if (index == 4 && parser->method == PHP_HTTP_PROPFIND && ch == 'P') {
@@ -1441,7 +1375,9 @@ size_t php_http_parser_execute (php_http_parser *parser,
}
case s_body_identity:
- to_read = MIN(pe - p, (size_t)parser->content_length);
+ assert(pe >= p);
+
+ to_read = MIN((size_t)(pe - p), (size_t)parser->content_length);
if (to_read > 0) {
if (settings->on_body) settings->on_body(parser, p, to_read);
p += to_read - 1;
@@ -1525,8 +1461,9 @@ size_t php_http_parser_execute (php_http_parser *parser,
case s_chunk_data:
{
assert(parser->flags & F_CHUNKED);
+ assert(pe >= p);
- to_read = MIN(pe - p, (size_t)(parser->content_length));
+ to_read = MIN((size_t)(pe - p), (size_t)(parser->content_length));
if (to_read > 0) {
if (settings->on_body) settings->on_body(parser, p, to_read);