]> granicus.if.org Git - php/commitdiff
- Added enable_post_data_reading ini option to allow inhibiting POST data consumption.
authorGustavo André dos Santos Lopes <cataphract@php.net>
Thu, 9 Dec 2010 20:35:59 +0000 (20:35 +0000)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Thu, 9 Dec 2010 20:35:59 +0000 (20:35 +0000)
main/SAPI.c
main/main.c
main/php_globals.h
tests/basic/enable_post_data_reading_01.phpt [new file with mode: 0644]
tests/basic/enable_post_data_reading_02.phpt [new file with mode: 0644]
tests/basic/enable_post_data_reading_03.phpt [new file with mode: 0644]
tests/basic/enable_post_data_reading_04.phpt [new file with mode: 0644]

index 7fa8775a9338fe8245927d6acb38f0c014ba6670..20942191542a0015d9b84d75642cb21e46f5fc4c 100644 (file)
@@ -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
index f58853f419a6562749f34c299be6e5280ce2a285..822f34e80d91fb72d0562f140417a869e821aeb2 100644 (file)
@@ -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)
index 921168e8c447e7959d9dd3dcd9bdb8734b5ccc6d..2ef234ae38b3165c9fd0d0b4d9ce7f4a6fa51595 100644 (file)
@@ -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 (file)
index 0000000..1a0e33f
--- /dev/null
@@ -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 (file)
index 0000000..395a220
--- /dev/null
@@ -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 (file)
index 0000000..cdabe91
--- /dev/null
@@ -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 (file)
index 0000000..a168504
--- /dev/null
@@ -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"