From 6654a4ade5da2c23ba39d6e89bd738f9819c5954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Andr=C3=A9=20dos=20Santos=20Lopes?= Date: Thu, 9 Dec 2010 20:35:59 +0000 Subject: [PATCH] - Added enable_post_data_reading ini option to allow inhibiting POST data consumption. --- main/SAPI.c | 2 +- main/main.c | 1 + main/php_globals.h | 1 + tests/basic/enable_post_data_reading_01.phpt | 22 +++++++++++++++ tests/basic/enable_post_data_reading_02.phpt | 28 ++++++++++++++++++++ tests/basic/enable_post_data_reading_03.phpt | 23 ++++++++++++++++ tests/basic/enable_post_data_reading_04.phpt | 23 ++++++++++++++++ 7 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 tests/basic/enable_post_data_reading_01.phpt create mode 100644 tests/basic/enable_post_data_reading_02.phpt create mode 100644 tests/basic/enable_post_data_reading_03.phpt create mode 100644 tests/basic/enable_post_data_reading_04.phpt diff --git a/main/SAPI.c b/main/SAPI.c index 7fa8775a933..20942191542 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -393,7 +393,7 @@ SAPI_API void sapi_activate(TSRMLS_D) /* handle request mehtod */ if (SG(server_context)) { - if ( SG(request_info).request_method) { + if (PG(enable_post_data_reading) && SG(request_info).request_method) { if(!strcmp(SG(request_info).request_method, "POST") && (SG(request_info).content_type)) { /* HTTP POST -> may contain form data to be read into variables diff --git a/main/main.c b/main/main.c index f58853f419a..822f34e80d9 100644 --- a/main/main.c +++ b/main/main.c @@ -490,6 +490,7 @@ PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("allow_url_fopen", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_url_fopen, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("allow_url_include", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_url_include, php_core_globals, core_globals) + STD_PHP_INI_BOOLEAN("enable_post_data_reading", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, enable_post_data_reading, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("always_populate_raw_post_data", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, always_populate_raw_post_data, php_core_globals, core_globals) STD_PHP_INI_ENTRY("realpath_cache_size", "16K", PHP_INI_SYSTEM, OnUpdateLong, realpath_cache_size_limit, virtual_cwd_globals, cwd_globals) diff --git a/main/php_globals.h b/main/php_globals.h index 921168e8c44..2ef234ae38b 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -132,6 +132,7 @@ struct _php_core_globals { zend_bool file_uploads; zend_bool during_request_startup; zend_bool allow_url_fopen; + zend_bool enable_post_data_reading; zend_bool always_populate_raw_post_data; zend_bool report_zend_debug; diff --git a/tests/basic/enable_post_data_reading_01.phpt b/tests/basic/enable_post_data_reading_01.phpt new file mode 100644 index 00000000000..1a0e33f6174 --- /dev/null +++ b/tests/basic/enable_post_data_reading_01.phpt @@ -0,0 +1,22 @@ +--TEST-- +enable_post_data_reading: basic test +--INI-- +enable_post_data_reading=0 +--POST_RAW-- +Content-Type: application/x-www-form-urlencoded +a=1&b=ZYX +--FILE-- +