X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_header_parser.c;h=975df2467e3d4b84ffa4f8437e807160ca713bac;hb=59ffe749e2571c7e4bf0cce12997f95f350bd58c;hp=2ad902280897ee852982238bd435d7668289fe3b;hpb=29a54250b58e444974ae19840194e214cab80bd5;p=m6w6%2Fext-http diff --git a/php_http_header_parser.c b/php_http_header_parser.c index 2ad9022..975df24 100644 --- a/php_http_header_parser.c +++ b/php_http_header_parser.c @@ -152,14 +152,18 @@ PHP_HTTP_API STATUS php_http_header_parser_parse(php_http_header_parser_t *parse const char *eol_str; int eol_len; - do { + line_split: { + if ((eol_str = php_http_locate_bin_eol(buffer->data, buffer->used, &eol_len))) { if (eol_str + eol_len - buffer->data < buffer->used) { - char nextline = *(eol_str + eol_len); - - if (nextline == '\t' || nextline == ' ') { - php_http_buffer_cut(buffer, eol_str - buffer->data, eol_len); - continue; + char *nextline = eol_str + eol_len; + + if (*nextline == '\t' || *nextline == ' ') { + while (nextline < buffer->data + buffer->used && (*nextline == '\t' || *nextline == ' ')) { + ++nextline; + } + php_http_buffer_cut(buffer, eol_str - buffer->data, nextline - eol_str); + goto line_split; } } @@ -175,7 +179,7 @@ PHP_HTTP_API STATUS php_http_header_parser_parse(php_http_header_parser_t *parse } else { return php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_VALUE); } - } while (0); + } break; }