From: Boris Madzar Date: Sun, 22 Mar 2015 04:54:12 +0000 (-0400) Subject: fix for bug #69076, fix handling of URLs with lone '?' as last character X-Git-Tag: RELEASE_2_4_2~4 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=860f294514633abead8ed6df000655a93e98a30c fix for bug #69076, fix handling of URLs with lone '?' as last character --- diff --git a/php_http_url.c b/php_http_url.c index 951af23..14ad6f7 100644 --- a/php_http_url.c +++ b/php_http_url.c @@ -1271,7 +1271,7 @@ static const char *parse_query(struct parse_state *state) tmp = ++state->ptr; state->url.query = &state->buffer[state->offset]; - do { + while(state->ptr < state->end) { switch (*state->ptr) { case '#': goto done; @@ -1323,7 +1323,9 @@ static const char *parse_query(struct parse_state *state) } state->ptr += mb - 1; } - } while (++state->ptr < state->end); + + ++state->ptr; + } done: state->buffer[state->offset++] = 0; diff --git a/tests/bug69076.phpt b/tests/bug69076.phpt new file mode 100644 index 0000000..cd64958 --- /dev/null +++ b/tests/bug69076.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #69076 (URL parsing throws exception on empty query string) +--SKIPIF-- + +--FILE-- + + +===DONE=== +--EXPECT-- +Test +http://foo.bar/ +===DONE===