hholzgra Fri Nov 8 03:41:53 2002 EDT
Modified files:
/php4/main SAPI.c php_content_types.c
Log:
fix for #20198:
"always_populate_raw_post_data = On" breaks HTTP file uploads
Index: php4/main/SAPI.c
diff -u php4/main/SAPI.c:1.153 php4/main/SAPI.c:1.154
--- php4/main/SAPI.c:1.153 Mon Oct 21 15:18:39 2002
+++ php4/main/SAPI.c Fri Nov 8 03:41:52 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: SAPI.c,v 1.153 2002/10/21 19:18:39 hholzgra Exp $ */
+/* $Id: SAPI.c,v 1.154 2002/11/08 08:41:52 hholzgra Exp $ */
#include <ctype.h>
#include <sys/stat.h>
@@ -150,15 +150,19 @@
}
}
+ /* now try to find an appropriate POST content handler */
if (zend_hash_find(&known_post_content_types, content_type,
content_type_length+1, (void **) &post_entry)==SUCCESS) {
+ /* found one, register it for use */
SG(request_info).post_entry = post_entry;
post_reader_func = post_entry->post_reader;
} else {
+ /* fallback */
+ SG(request_info).post_entry = NULL;
if (!sapi_module.default_post_reader) {
+ /* no default reader ? */
sapi_module.sapi_error(E_WARNING, "Unsupported content type:
'%s'", content_type);
return;
}
- SG(request_info).post_entry = NULL;
}
if (oldchar) {
*(p-1) = oldchar;
Index: php4/main/php_content_types.c
diff -u php4/main/php_content_types.c:1.22 php4/main/php_content_types.c:1.23
--- php4/main/php_content_types.c:1.22 Mon Oct 21 12:41:06 2002
+++ php4/main/php_content_types.c Fri Nov 8 03:41:52 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_content_types.c,v 1.22 2002/10/21 16:41:06 hholzgra Exp $ */
+/* $Id: php_content_types.c,v 1.23 2002/11/08 08:41:52 hholzgra Exp $ */
#include "php.h"
#include "SAPI.h"
@@ -37,12 +37,25 @@
*/
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
{
- char *data;
+ char *data = NULL;
if(PG(always_populate_raw_post_data)) {
- if(!SG(request_info).post_data) sapi_read_standard_form_data(TSRMLS_C);
- data = estrndup(SG(request_info).post_data,
SG(request_info).post_data_length);
- SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data,
SG(request_info).post_data_length);
+ if(NULL == SG(request_info).post_data) { /* no data yet */
+ if(NULL == SG(request_info).post_entry) {
+ /* no post handler registered, so we just swallow the
+data */
+ sapi_read_standard_form_data(TSRMLS_C);
+ data = SG(request_info).post_data;
+ SG(request_info).post_data = NULL;
+ SG(request_info).post_data_length = 0;
+ }
+ } else {
+ /* copy existing post data */
+ data = estrndup(SG(request_info).post_data,
+SG(request_info).post_data_length);
+ }
+
+ if(data) {
+ SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data,
+SG(request_info).post_data_length);
+ }
}
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php