summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2010-12-09 20:35:59 +0000
committerGustavo André dos Santos Lopes <cataphract@php.net>2010-12-09 20:35:59 +0000
commit6654a4ade5da2c23ba39d6e89bd738f9819c5954 (patch)
tree73a38cfb6f9fab9c287da6957c69a9111146a577
parentc35fc7889025816f76d142b43a3a2452a59869d5 (diff)
downloadphp-git-6654a4ade5da2c23ba39d6e89bd738f9819c5954.tar.gz
- Added enable_post_data_reading ini option to allow inhibiting POST data consumption.
-rw-r--r--main/SAPI.c2
-rw-r--r--main/main.c1
-rw-r--r--main/php_globals.h1
-rw-r--r--tests/basic/enable_post_data_reading_01.phpt22
-rw-r--r--tests/basic/enable_post_data_reading_02.phpt28
-rw-r--r--tests/basic/enable_post_data_reading_03.phpt23
-rw-r--r--tests/basic/enable_post_data_reading_04.phpt23
7 files changed, 99 insertions, 1 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index 7fa8775a93..2094219154 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 f58853f419..822f34e80d 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 921168e8c4..2ef234ae38 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 0000000000..1a0e33f617
--- /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--
+<?php
+var_dump($_FILES);
+var_dump($_POST);
+var_dump($HTTP_RAW_POST_DATA);
+var_dump(file_get_contents("php://input"));
+--EXPECTF--
+array(0) {
+}
+array(0) {
+}
+
+Notice: Undefined variable: HTTP_RAW_POST_DATA in %s on line %d
+NULL
+string(9) "a=1&b=ZYX"
diff --git a/tests/basic/enable_post_data_reading_02.phpt b/tests/basic/enable_post_data_reading_02.phpt
new file mode 100644
index 0000000000..395a220e51
--- /dev/null
+++ b/tests/basic/enable_post_data_reading_02.phpt
@@ -0,0 +1,28 @@
+--TEST--
+enable_post_data_reading: rfc1867
+--INI--
+enable_post_data_reading=0
+--POST_RAW--
+Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file1"; filename="file1.txt"
+Content-Type: text/plain-file
+
+1
+-----------------------------20896060251896012921717172737--
+--FILE--
+<?php
+var_dump($_FILES);
+var_dump($_POST);
+var_dump(file_get_contents("php://input"));
+--EXPECTF--
+array(0) {
+}
+array(0) {
+}
+string(224) "-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file1"; filename="file1.txt"
+Content-Type: text/plain-file
+
+1
+-----------------------------20896060251896012921717172737--"
diff --git a/tests/basic/enable_post_data_reading_03.phpt b/tests/basic/enable_post_data_reading_03.phpt
new file mode 100644
index 0000000000..cdabe910ca
--- /dev/null
+++ b/tests/basic/enable_post_data_reading_03.phpt
@@ -0,0 +1,23 @@
+--TEST--
+enable_post_data_reading: always_populate_raw_post_data has no effect (1)
+--INI--
+enable_post_data_reading=0
+always_populate_raw_post_data=1
+--POST_RAW--
+Content-Type: application/x-www-form-urlencoded
+a=1&b=ZYX
+--FILE--
+<?php
+var_dump($_FILES);
+var_dump($_POST);
+var_dump($HTTP_RAW_POST_DATA);
+var_dump(file_get_contents("php://input"));
+--EXPECTF--
+array(0) {
+}
+array(0) {
+}
+
+Notice: Undefined variable: HTTP_RAW_POST_DATA in %s on line %d
+NULL
+string(9) "a=1&b=ZYX"
diff --git a/tests/basic/enable_post_data_reading_04.phpt b/tests/basic/enable_post_data_reading_04.phpt
new file mode 100644
index 0000000000..a1685040bb
--- /dev/null
+++ b/tests/basic/enable_post_data_reading_04.phpt
@@ -0,0 +1,23 @@
+--TEST--
+enable_post_data_reading: always_populate_raw_post_data has no effect (2)
+--INI--
+enable_post_data_reading=0
+always_populate_raw_post_data=1
+--POST_RAW--
+Content-Type: application/unknown
+a=1&b=ZYX
+--FILE--
+<?php
+var_dump($_FILES);
+var_dump($_POST);
+var_dump($HTTP_RAW_POST_DATA);
+var_dump(file_get_contents("php://input"));
+--EXPECTF--
+array(0) {
+}
+array(0) {
+}
+
+Notice: Undefined variable: HTTP_RAW_POST_DATA in %s on line %d
+NULL
+string(9) "a=1&b=ZYX"