diff options
author | Christopher Jones <sixd@php.net> | 2012-09-16 18:37:35 -0700 |
---|---|---|
committer | Christopher Jones <sixd@php.net> | 2012-09-16 18:37:35 -0700 |
commit | e1419001bd1d60de07b8b31d7e7dfcfc67fceafd (patch) | |
tree | a8e0fe606b532e8934f7a03701e84d8a391bbefe | |
parent | b7fa9bfc044f8b1499aaabf0ec725b20b63a33d2 (diff) | |
parent | f163c70feae301ff259aca8eb0929f3a4b70a1c1 (diff) | |
download | php-git-e1419001bd1d60de07b8b31d7e7dfcfc67fceafd.tar.gz |
Merge branch 'master' of https://git.php.net/repository/php-src
* 'master' of https://git.php.net/repository/php-src:
Add NEWS for generators
Fix two op_array -> function cast warnings
Replace code with zend_clean_and_cache_symbol_table() call
Fix invalid read / remove useless code
Respond with 501 to unknown request methods
news for bug #61421
commit for php bug 61421 enabling SHA2 and RMD160 for openssl signature verification
Fixed bug #63093 (Segfault while load extension failed in zts-build).
Remove bug fixed entry
Add XFAIL test for bug #62852
Revert "Fixed bug #62852 (Unserialize invalid DateTime causes crash)"
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | Zend/zend_API.c | 4 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 10 | ||||
-rw-r--r-- | Zend/zend_generators.c | 2 | ||||
-rw-r--r-- | Zend/zend_vm_def.h | 10 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 10 | ||||
-rw-r--r-- | ext/date/php_date.c | 16 | ||||
-rw-r--r-- | ext/date/tests/bug62852.phpt | 30 | ||||
-rw-r--r-- | ext/openssl/openssl.c | 32 | ||||
-rw-r--r-- | sapi/cli/php_cli_server.c | 41 | ||||
-rw-r--r-- | sapi/cli/php_http_parser.c | 7 | ||||
-rw-r--r-- | sapi/cli/php_http_parser.h | 2 | ||||
-rw-r--r-- | sapi/cli/tests/bug61679.phpt | 43 |
13 files changed, 141 insertions, 68 deletions
@@ -3,6 +3,8 @@ PHP NEWS ?? ??? 201?, PHP 5.5.0 - General improvements: + . Add generators and coroutines (https://wiki.php.net/rfc/generators). + (Nikita Popov) . Support list in foreach (https://wiki.php.net/rfc/foreachlist). (Laruence) . Implemented 'finally' keyword (https://wiki.php.net/rfc/finally). (Laruence) . Drop Windows XP and 2003 support. (Pierre) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index a231415547..3c9d59d692 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2265,7 +2265,9 @@ void module_destructor(zend_module_entry *module) /* {{{ */ /* Deinitilaise module globals */ if (module->globals_size) { #ifdef ZTS - ts_free_id(*module->globals_id_ptr); + if (*module->globals_id_ptr) { + ts_free_id(*module->globals_id_ptr); + } #else if (module->globals_dtor) { module->globals_dtor(module->globals_ptr TSRMLS_CC); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index fb0c18b27c..ddf86e8008 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -964,15 +964,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS } if (!fci->symbol_table && EG(active_symbol_table)) { - if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { - zend_hash_destroy(EG(active_symbol_table)); - FREE_HASHTABLE(EG(active_symbol_table)); - } else { - /* clean before putting into the cache, since clean - could call dtors, which could use cached hash */ - zend_hash_clean(EG(active_symbol_table)); - *(++EG(symtable_cache_ptr)) = EG(active_symbol_table); - } + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } EG(active_symbol_table) = calling_symbol_table; EG(active_op_array) = original_op_array; diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 83025eacd1..01b33a3a3c 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -371,7 +371,7 @@ zval *zend_generator_create_zval(zend_op_array *op_array TSRMLS_DC) /* {{{ */ if (op_array->fn_flags & ZEND_ACC_CLOSURE) { zend_op_array *op_array_copy = (zend_op_array*)emalloc(sizeof(zend_op_array)); *op_array_copy = *op_array; - function_add_ref(op_array_copy); + function_add_ref((zend_function *) op_array_copy); op_array = op_array_copy; } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index f683ff2972..e0fc1bfc5b 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1869,13 +1869,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) nested = EX(nested); - /* For generators the execute_data is stored on the heap, for everything - * else it is stored on the VM stack. */ - if (op_array->fn_flags & ZEND_ACC_GENERATOR) { - efree(execute_data); - } else { - zend_vm_stack_free(execute_data TSRMLS_CC); - } + zend_vm_stack_free(execute_data TSRMLS_CC); if (nested) { execute_data = EG(current_execute_data); @@ -5346,7 +5340,7 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED) zend_error_noreturn(E_ERROR, "Base lambda function for closure not found"); } - zend_create_closure(&EX_T(opline->result.var).tmp_var, op_array, EG(scope), EG(This) TSRMLS_CC); + zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(scope), EG(This) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index f8a8905040..b8dac02cba 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -493,13 +493,7 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) nested = EX(nested); - /* For generators the execute_data is stored on the heap, for everything - * else it is stored on the VM stack. */ - if (op_array->fn_flags & ZEND_ACC_GENERATOR) { - efree(execute_data); - } else { - zend_vm_stack_free(execute_data TSRMLS_CC); - } + zend_vm_stack_free(execute_data TSRMLS_CC); if (nested) { execute_data = EG(current_execute_data); @@ -6620,7 +6614,7 @@ static int ZEND_FASTCALL ZEND_DECLARE_LAMBDA_FUNCTION_SPEC_CONST_UNUSED_HANDLER zend_error_noreturn(E_ERROR, "Base lambda function for closure not found"); } - zend_create_closure(&EX_T(opline->result.var).tmp_var, op_array, EG(scope), EG(This) TSRMLS_CC); + zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(scope), EG(This) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 765da9ec45..1b36894da8 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2468,9 +2468,6 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) { convert_to_long(*z_timezone_type); if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) { - zend_error_handling error_handling; - - zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); convert_to_string(*z_timezone); switch (Z_LVAL_PP(z_timezone_type)) { @@ -2478,9 +2475,9 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat case TIMELIB_ZONETYPE_ABBR: { char *tmp = emalloc(Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2); snprintf(tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2, "%s %s", Z_STRVAL_PP(z_date), Z_STRVAL_PP(z_timezone)); - php_date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 1 TSRMLS_CC); + php_date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 0 TSRMLS_CC); efree(tmp); - break; + return 1; } case TIMELIB_ZONETYPE_ID: @@ -2494,15 +2491,10 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat tzobj->tzi.tz = tzi; tzobj->initialized = 1; - php_date_initialize(*dateobj, Z_STRVAL_PP(z_date), Z_STRLEN_PP(z_date), NULL, tmp_obj, 1 TSRMLS_CC); + php_date_initialize(*dateobj, Z_STRVAL_PP(z_date), Z_STRLEN_PP(z_date), NULL, tmp_obj, 0 TSRMLS_CC); zval_ptr_dtor(&tmp_obj); - break; - default: - zend_restore_error_handling(&error_handling TSRMLS_CC); - return 0; + return 1; } - zend_restore_error_handling(&error_handling TSRMLS_CC); - return 1; } } } diff --git a/ext/date/tests/bug62852.phpt b/ext/date/tests/bug62852.phpt index 6426a80fb8..2c23138035 100644 --- a/ext/date/tests/bug62852.phpt +++ b/ext/date/tests/bug62852.phpt @@ -2,14 +2,32 @@ Bug #62852 (Unserialize invalid DateTime causes crash) --INI-- date.timezone=GMT +--XFAIL-- +bug is not fixed yet --FILE-- <?php -try { - $datetime = unserialize('O:8:"DateTime":3:{s:4:"date";s:20:"10007-06-07 03:51:49";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}'); - var_dump($datetime); -} catch (Exception $e) { - var_dump($e->getMessage()); +$s1 = 'O:8:"DateTime":3:{s:4:"date";s:20:"10007-06-07 03:51:49";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}'; +$s2 = 'O:3:"Foo":3:{s:4:"date";s:20:"10007-06-07 03:51:49";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}'; + +global $foo; + +class Foo extends DateTime { + function __wakeup() { + global $foo; + $foo = $this; + parent::__wakeup(); + } } + +// Old test case +try { + unserialize( $s1 ); +} catch ( Exception $e ) {} + +// My test case +try { + unserialize( $s2 ); +} catch ( Exception $e ) {} +var_dump( $foo ); ?> --EXPECTF-- -string(%d) "DateTime::__wakeup(): Failed to parse time string (%s) at position 12 (0): Double time specification" diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 938e0e1f75..99735b1544 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -65,7 +65,13 @@ #define OPENSSL_ALGO_MD2 4 #endif #define OPENSSL_ALGO_DSS1 5 - +#if OPENSSL_VERSION_NUMBER >= 0x0090708fL +#define OPENSSL_ALGO_SHA224 6 +#define OPENSSL_ALGO_SHA256 7 +#define OPENSSL_ALGO_SHA384 8 +#define OPENSSL_ALGO_SHA512 9 +#define OPENSSL_ALGO_RMD160 10 +#endif #define DEBUG_SMIME 0 /* FIXME: Use the openssl constants instead of @@ -964,6 +970,23 @@ static EVP_MD * php_openssl_get_evp_md_from_algo(long algo) { /* {{{ */ case OPENSSL_ALGO_DSS1: mdtype = (EVP_MD *) EVP_dss1(); break; +#if OPENSSL_VERSION_NUMBER >= 0x0090708fL + case OPENSSL_ALGO_SHA224: + mdtype = (EVP_MD *) EVP_sha224(); + break; + case OPENSSL_ALGO_SHA256: + mdtype = (EVP_MD *) EVP_sha256(); + break; + case OPENSSL_ALGO_SHA384: + mdtype = (EVP_MD *) EVP_sha384(); + break; + case OPENSSL_ALGO_SHA512: + mdtype = (EVP_MD *) EVP_sha512(); + break; + case OPENSSL_ALGO_RMD160: + mdtype = (EVP_MD *) EVP_ripemd160(); + break; +#endif default: return NULL; break; @@ -1058,6 +1081,13 @@ PHP_MINIT_FUNCTION(openssl) REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD2", OPENSSL_ALGO_MD2, CONST_CS|CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("OPENSSL_ALGO_DSS1", OPENSSL_ALGO_DSS1, CONST_CS|CONST_PERSISTENT); +#if OPENSSL_VERSION_NUMBER >= 0x0090708fL + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA224", OPENSSL_ALGO_SHA224, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA256", OPENSSL_ALGO_SHA256, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA384", OPENSSL_ALGO_SHA384, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA512", OPENSSL_ALGO_SHA512, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_RMD160", OPENSSL_ALGO_RMD160, CONST_CS|CONST_PERSISTENT); +#endif /* flags for S/MIME */ REGISTER_LONG_CONSTANT("PKCS7_DETACHED", PKCS7_DETACHED, CONST_CS|CONST_PERSISTENT); diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 89262e863d..c40e34affe 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -116,7 +116,7 @@ typedef struct php_cli_server_poller { } php_cli_server_poller; typedef struct php_cli_server_request { - enum php_http_method request_method; + enum php_http_method request_method; int protocol_version; char *request_uri; size_t request_uri_len; @@ -247,7 +247,8 @@ static php_cli_server_http_reponse_status_code_pair status_map[] = { static php_cli_server_http_reponse_status_code_pair template_map[] = { { 400, "<h1 class=\"h\">%s</h1><p>Your browser sent a request that this server could not understand.</p>" }, { 404, "<h1 class=\"h\">%s</h1><p>The requested resource %s was not found on this server.</p>" }, - { 500, "<h1 class=\"h\">%s</h1><p>The server is temporality unavaiable.</p>" } + { 500, "<h1 class=\"h\">%s</h1><p>The server is temporarily unavailable.</p>" }, + { 501, "<h1 class=\"h\">%s</h1><p>Request method not supported.</p>" } }; static php_cli_server_ext_mime_type_pair mime_type_map[] = { @@ -275,7 +276,7 @@ static void php_cli_server_log_response(php_cli_server_client *client, int statu ZEND_DECLARE_MODULE_GLOBALS(cli_server); -/* {{{ static char php_cli_server_css[] +/* {{{ static char php_cli_server_css[] * copied from ext/standard/info.c */ static const char php_cli_server_css[] = "<style type=\"text/css\">\n" \ @@ -543,7 +544,7 @@ static void sapi_cli_server_register_variable(zval *track_vars_array, const char } } /* }}} */ -static int sapi_cli_server_register_entry_cb(char **entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { +static int sapi_cli_server_register_entry_cb(char **entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { zval *track_vars_array = va_arg(args, zval *); if (hash_key->nKeyLength) { char *real_key, *key; @@ -583,7 +584,7 @@ static void sapi_cli_server_register_variables(zval *track_vars_array TSRMLS_DC) } else { sapi_cli_server_register_variable(track_vars_array, "REMOTE_ADDR", client->addr_str TSRMLS_CC); } - } + } { char *tmp; spprintf(&tmp, 0, "PHP %s Development Server", PHP_VERSION); @@ -681,7 +682,7 @@ sapi_module_struct cli_server_sapi_module = { sapi_cli_server_log_message, /* Log message */ NULL, /* Get request time */ NULL, /* Child terminate */ - + STANDARD_SAPI_MODULE_PROPERTIES }; /* }}} */ @@ -778,7 +779,7 @@ static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, v } } } - + #else php_socket_t fd = 0; const php_socket_t max_fd = poller->max_fd; @@ -966,7 +967,7 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender *sen } else if (nbytes_sent == chunk->data.immortal.len) { php_cli_server_chunk_dtor(chunk); pefree(chunk, 1); - sender->buffer.first = next; + sender->buffer.first = next; if (!next) { sender->buffer.last = NULL; } @@ -1345,7 +1346,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque } } break; /* regular file */ - } + } if (prev_path) { pefree(prev_path, 1); *q = DEFAULT_SLASH; @@ -1384,7 +1385,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque if (request->vpath[i] == '\\') { request->vpath[i] = '/'; } - } + } } #endif request->sb = sb; @@ -1452,7 +1453,7 @@ static void normalize_vpath(char **retval, size_t *retval_len, const char *vpath } } } - + *decoded_vpath_end = '\0'; *retval = decoded_vpath; *retval_len = decoded_vpath_end - decoded_vpath; @@ -1812,7 +1813,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server smart_str_append_generic_ex(&buffer, php_cli_server_buffer_size(&client->content_sender.buffer), 1, size_t, _unsigned); smart_str_appendl_ex(&buffer, "\r\n", 2, 1); smart_str_appendl_ex(&buffer, "\r\n", 2, 1); - + chunk = php_cli_server_chunk_heap_new(buffer.c, buffer.c, buffer.len); if (!chunk) { smart_str_free_ex(&buffer, 1); @@ -1917,7 +1918,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) { /* {{{ */ +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)) { @@ -1942,8 +1943,8 @@ static int php_cli_server_request_shutdown(php_cli_server *server, php_cli_serve SG(server_context) = NULL; SG(rfc1867_uploaded_files) = NULL; return SUCCESS; -} -/* }}} */ +} +/* }}} */ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */ { @@ -2000,7 +2001,7 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client destroy_request_info(&SG(request_info)); return SUCCESS; } - } + } if (server->router) { if (!php_cli_server_dispatch_router(server, client TSRMLS_CC)) { @@ -2014,7 +2015,7 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client || SUCCESS != php_cli_server_send_error_page(server, client, 500 TSRMLS_CC)) { php_cli_server_request_shutdown(server, client TSRMLS_CC); return SUCCESS; - } + } } else { if (server->router) { static int (*send_header_func)(sapi_headers_struct * TSRMLS_DC); @@ -2027,7 +2028,7 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client sapi_module.send_headers = send_header_func; SG(sapi_headers).send_default_content_type = 1; SG(rfc1867_uploaded_files) = NULL; - } + } if (SUCCESS != php_cli_server_begin_send_static(server, client TSRMLS_CC)) { php_cli_server_close_connection(server, client TSRMLS_CC); } @@ -2189,6 +2190,8 @@ static int php_cli_server_recv_event_read_request(php_cli_server *server, php_cl efree(errstr); php_cli_server_close_connection(server, client TSRMLS_CC); return FAILURE; + } else if (status == 1 && client->request.request_method == PHP_HTTP_NOT_IMPLEMENTED) { + return php_cli_server_send_error_page(server, client, 501 TSRMLS_CC); } else if (status == 1) { php_cli_server_poller_remove(&server->poller, POLLIN, client->sock); php_cli_server_dispatch(server, client TSRMLS_CC); @@ -2309,7 +2312,7 @@ static void php_cli_server_do_event_for_each_fd(php_cli_server *server, int(*rha static int php_cli_server_do_event_loop(php_cli_server *server TSRMLS_DC) /* {{{ */ { int retval = SUCCESS; - while (server->is_running) { + while (server->is_running) { static const struct timeval tv = { 1, 0 }; int n = php_cli_server_poller_poll(&server->poller, &tv); if (n > 0) { diff --git a/sapi/cli/php_http_parser.c b/sapi/cli/php_http_parser.c index 13b9ea12bc..4a95f82575 100644 --- a/sapi/cli/php_http_parser.c +++ b/sapi/cli/php_http_parser.c @@ -99,6 +99,7 @@ static const char *method_strings[] = , "NOTIFY" , "SUBSCRIBE" , "UNSUBSCRIBE" + , "NOTIMPLEMENTED" }; @@ -589,7 +590,7 @@ size_t php_http_parser_execute (php_http_parser *parser, case 'S': parser->method = PHP_HTTP_SUBSCRIBE; break; case 'T': parser->method = PHP_HTTP_TRACE; break; case 'U': parser->method = PHP_HTTP_UNLOCK; /* or UNSUBSCRIBE */ break; - default: goto error; + default: parser->method = PHP_HTTP_NOT_IMPLEMENTED; break; } state = s_req_method; break; @@ -602,7 +603,7 @@ size_t php_http_parser_execute (php_http_parser *parser, goto error; matcher = method_strings[parser->method]; - if (ch == ' ' && matcher[index] == '\0') { + if (ch == ' ' && (matcher[index] == '\0' || parser->method == PHP_HTTP_NOT_IMPLEMENTED)) { state = s_req_spaces_before_url; } else if (ch == matcher[index]) { ; /* nada */ @@ -631,7 +632,7 @@ size_t php_http_parser_execute (php_http_parser *parser, } else if (index == 4 && parser->method == PHP_HTTP_PROPFIND && ch == 'P') { parser->method = PHP_HTTP_PROPPATCH; } else { - goto error; + parser->method = PHP_HTTP_NOT_IMPLEMENTED; } ++index; diff --git a/sapi/cli/php_http_parser.h b/sapi/cli/php_http_parser.h index 7e72b78d7d..0f6c13dd35 100644 --- a/sapi/cli/php_http_parser.h +++ b/sapi/cli/php_http_parser.h @@ -102,6 +102,8 @@ enum php_http_method , PHP_HTTP_NOTIFY , PHP_HTTP_SUBSCRIBE , PHP_HTTP_UNSUBSCRIBE + /* unknown, not implemented */ + , PHP_HTTP_NOT_IMPLEMENTED }; diff --git a/sapi/cli/tests/bug61679.phpt b/sapi/cli/tests/bug61679.phpt new file mode 100644 index 0000000000..819ce2fa89 --- /dev/null +++ b/sapi/cli/tests/bug61679.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #61679 (Error on non-standard HTTP methods) +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; +php_cli_server_start(<<<'PHP' +echo "This should never echo"; +PHP +); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)?:80; + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +// Send a request with a fictitious request method, +// I like smurfs, the smurf everything. +if(fwrite($fp, <<<HEADER +SMURF / HTTP/1.1 +Host: {$host} + + +HEADER +)) { + while (!feof($fp)) { + echo fgets($fp); + // Only echo the first line from the response, + // the rest is not interesting + break; + } +} + +fclose($fp); +?> +--EXPECTF-- +HTTP/1.1 501 Not Implemented |