com php-src: Fix #77794: Incorrect Date header format in built-in server: sapi/cli/php_cli_server.c

From: Date: Mon, 25 Mar 2019 20:41:45 +0000
Subject: com php-src: Fix #77794: Incorrect Date header format in built-in server: sapi/cli/php_cli_server.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-105338@lists.php.net to get a copy of this message
Commit: 7f9872387e38a05b11ce233b4d142325d742c487 Author: Niklas Keller <me@kelunik.com> Sun, 24 Mar 2019 19:39:25 +0100 Committer: Peter Kokot <peterkokot@gmail.com> Mon, 25 Mar 2019 21:41:45 +0100 Parents: ec2ecb7e12b96f8f95af2885d173a0d46c88e190 Branches: PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7f9872387e38a05b11ce233b4d142325d742c487 Log: Fix #77794: Incorrect Date header format in built-in server - Fix the date format to be compliant with https://tools.ietf.org/html/rfc7231#section-7.1.1.2 - Fix date format length and use GMT time - Previously, local time was used instead of GMT. - Remove extra whitespace - Simplify string appends in php_cli_server.c Bugs: https://bugs.php.net/77794 Changed paths: M sapi/cli/php_cli_server.c Diff: diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 198afc8..cdcd93a 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -349,17 +349,16 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c struct timeval tv = {0}; if (NULL != (val = zend_hash_str_find_ptr(&client->request.headers, "host", sizeof("host")-1))) { - smart_str_appendl_ex(buffer, "Host", sizeof("Host") - 1, persistent); - smart_str_appendl_ex(buffer, ": ", sizeof(": ") - 1, persistent); + smart_str_appends_ex(buffer, "Host: ", persistent); smart_str_appends_ex(buffer, val, persistent); - smart_str_appendl_ex(buffer, "\r\n", 2, persistent); + smart_str_appends_ex(buffer, "\r\n", persistent); } if (!gettimeofday(&tv, NULL)) { - zend_string *dt = php_format_date("r", 1, tv.tv_sec, 1); - smart_str_appendl_ex(buffer, "Date: ", 6, persistent); + zend_string *dt = php_format_date("D, d M Y H:i:s", sizeof("D, d M Y H:i:s") - 1, tv.tv_sec, 0); + smart_str_appends_ex(buffer, "Date: ", persistent); smart_str_appends_ex(buffer, dt->val, persistent); - smart_str_appendl_ex(buffer, "\r\n", 2, persistent); + smart_str_appends_ex(buffer, " GMT\r\n", persistent); zend_string_release(dt); }

« previous php.cvs (#105338) next »