Hi,

I prepared the attached patch for the PHP5 packages that I build for my
personal use. It is actually
http://cvs.php.net/viewcvs.cgi/php-src/main/php_content_types.c?hideattic=1&r1=1.32.2.1.2.2&r2=1.32.2.1.2.4&view=patch
with the paths fixed. I hope this helps.

Best regards,
Martijn Grendelman
--- php5/main/php_content_types.c.old   2007/04/01 19:09:36     1.32.2.1.2.2
+++ php5/main/php_content_types.c       2007/05/07 23:27:59     1.32.2.1.2.4
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_content_types.c,v 1.32.2.1.2.2 2007/04/01 19:09:36 iliaa Exp $ */
+/* $Id: php_content_types.c,v 1.32.2.1.2.4 2007/05/07 23:27:59 iliaa Exp $ */
 
 #include "php.h"
 #include "SAPI.h"
@@ -37,21 +37,21 @@
  */
 SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
 {
-       char *data = NULL;
-       int length = 0;
+       char *data;
+       int length;
 
        /* $HTTP_RAW_POST_DATA registration */
-       if(!strcmp(SG(request_info).request_method, "POST")) {
-               if(NULL == SG(request_info).post_entry && 
SG(request_info).post_data) {
+       if (!strcmp(SG(request_info).request_method, "POST")) {
+               if (NULL == SG(request_info).post_entry) {
                        /* no post handler registered, so we just swallow the 
data */
                        sapi_read_standard_form_data(TSRMLS_C);
+               }
+
+               /* For unknown content types we create HTTP_RAW_POST_DATA even 
if always_populate_raw_post_data off,
+                * this is in-effecient, but we need to keep doing it for BC 
reasons (for now) */
+               if ((PG(always_populate_raw_post_data) || NULL == 
SG(request_info).post_entry) && SG(request_info).post_data) {
                        length = SG(request_info).post_data_length;
                        data = estrndup(SG(request_info).post_data, length);
-               } else if(PG(always_populate_raw_post_data) && 
SG(request_info).post_data) {
-                       length = SG(request_info).post_data_length;
-                       data = estrndup(SG(request_info).post_data, length);
-               }
-               if(data) {
                        SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);
                }
        }
@@ -62,11 +62,10 @@
         in the long run post handlers should be changed to not touch
         request_info.post_data for memory preservation reasons
        */
-       if(SG(request_info).post_data) {
+       if (SG(request_info).post_data) {
                SG(request_info).raw_post_data = 
estrndup(SG(request_info).post_data, SG(request_info).post_data_length);
                SG(request_info).raw_post_data_length = 
SG(request_info).post_data_length;
        }
-
 }
 /* }}} */
 

Reply via email to