From 7beef74a827f393753852f7239af75af236fb4f8 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Tue, 3 Sep 2013 13:38:15 -0700 Subject: 5.4.21 now --- NEWS | 2 ++ configure.in | 2 +- main/php_version.h | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 76eb1faa0d..486ccb2a88 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +?? ??? 2013, PHP 5.4.21 + ?? ??? 2013, PHP 5.4.20 - Core: diff --git a/configure.in b/configure.in index 9a99680a47..30de2c3aaa 100644 --- a/configure.in +++ b/configure.in @@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...); PHP_MAJOR_VERSION=5 PHP_MINOR_VERSION=4 -PHP_RELEASE_VERSION=20 +PHP_RELEASE_VERSION=21 PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` diff --git a/main/php_version.h b/main/php_version.h index 9dc00237fe..e30528ed51 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 #define PHP_MINOR_VERSION 4 -#define PHP_RELEASE_VERSION 20 +#define PHP_RELEASE_VERSION 21 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "5.4.20-dev" -#define PHP_VERSION_ID 50420 +#define PHP_VERSION "5.4.21-dev" +#define PHP_VERSION_ID 50421 -- cgit v1.2.1 From 3c3b2b5bdc8e2bcff4d0e7d09375ad7af760b32a Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Mon, 9 Sep 2013 16:24:49 -0700 Subject: Handle CLI server request headers case insensitively. Fixes bug #65633 (built-in server treat some http headers as case-sensitive). --- NEWS | 4 ++++ sapi/cli/php_cli_server.c | 17 +++++++--------- sapi/cli/tests/bug65633.phpt | 48 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 sapi/cli/tests/bug65633.phpt diff --git a/NEWS b/NEWS index 486ccb2a88..e05b24042b 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2013, PHP 5.4.21 +- CLI server: + . Fixed bug #65633 (built-in server treat some http headers as + case-sensitive). (Adam) + ?? ??? 2013, PHP 5.4.20 - Core: diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 5a12134a91..4da55acc6c 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -408,7 +408,7 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c { { char **val; - if (SUCCESS == zend_hash_find(&client->request.headers, "Host", sizeof("Host"), (void**)&val)) { + if (SUCCESS == zend_hash_find(&client->request.headers, "host", sizeof("host"), (void**)&val)) { smart_str_appendl_ex(buffer, "Host", sizeof("Host") - 1, persistent); smart_str_appendl_ex(buffer, ": ", sizeof(": ") - 1, persistent); smart_str_appends_ex(buffer, *val, persistent); @@ -558,7 +558,7 @@ static char *sapi_cli_server_read_cookies(TSRMLS_D) /* {{{ */ { php_cli_server_client *client = SG(server_context); char **val; - if (FAILURE == zend_hash_find(&client->request.headers, "Cookie", sizeof("Cookie"), (void**)&val)) { + if (FAILURE == zend_hash_find(&client->request.headers, "cookie", sizeof("cookie"), (void**)&val)) { return NULL; } return *val; @@ -1556,12 +1556,9 @@ static int php_cli_server_client_read_request_on_header_value(php_http_parser *p return 1; } { - char *header_name = client->current_header_name; - size_t header_name_len = client->current_header_name_len; - char c = header_name[header_name_len]; - header_name[header_name_len] = '\0'; - zend_hash_add(&client->request.headers, header_name, header_name_len + 1, &value, sizeof(char *), NULL); - header_name[header_name_len] = c; + char *header_name = zend_str_tolower_dup(client->current_header_name, client->current_header_name_len); + zend_hash_add(&client->request.headers, header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL); + efree(header_name); } if (client->current_header_name_allocated) { @@ -1719,7 +1716,7 @@ static void php_cli_server_client_populate_request_info(const php_cli_server_cli request_info->post_data = client->request.content; request_info->content_length = request_info->post_data_length = client->request.content_len; request_info->auth_user = request_info->auth_password = request_info->auth_digest = NULL; - if (SUCCESS == zend_hash_find(&client->request.headers, "Content-Type", sizeof("Content-Type"), (void**)&val)) { + if (SUCCESS == zend_hash_find(&client->request.headers, "content-type", sizeof("content-type"), (void**)&val)) { request_info->content_type = *val; } } /* }}} */ @@ -1957,7 +1954,7 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv static int php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) { /* {{{ */ char **auth; php_cli_server_client_populate_request_info(client, &SG(request_info)); - if (SUCCESS == zend_hash_find(&client->request.headers, "Authorization", sizeof("Authorization"), (void**)&auth)) { + if (SUCCESS == zend_hash_find(&client->request.headers, "authorization", sizeof("authorization"), (void**)&auth)) { php_handle_auth_data(*auth TSRMLS_CC); } SG(sapi_headers).http_response_code = 200; diff --git a/sapi/cli/tests/bug65633.phpt b/sapi/cli/tests/bug65633.phpt new file mode 100644 index 0000000000..55834095b1 --- /dev/null +++ b/sapi/cli/tests/bug65633.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #65633 (built-in server treat some http headers as case-sensitive) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Connection: close +X-Powered-By: %s +Content-type: text/html + +array(1) { + ["foo"]=> + string(3) "bar" +} +string(3) "bar" -- cgit v1.2.1