Skip to content

Commit

Permalink
fix for #20198:
Browse files Browse the repository at this point in the history
"always_populate_raw_post_data = On" breaks HTTP file uploads
  • Loading branch information
Hartmut Holzgraefe committed Nov 8, 2002
1 parent 72e0aa8 commit 5aec6f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 5 additions & 1 deletion main/SAPI.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -150,15 +150,19 @@ static void sapi_read_post_data(TSRMLS_D)
} }
} }


/* 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) { 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; SG(request_info).post_entry = post_entry;
post_reader_func = post_entry->post_reader; post_reader_func = post_entry->post_reader;
} else { } else {
/* fallback */
SG(request_info).post_entry = NULL;
if (!sapi_module.default_post_reader) { if (!sapi_module.default_post_reader) {
/* no default reader ? */
sapi_module.sapi_error(E_WARNING, "Unsupported content type: '%s'", content_type); sapi_module.sapi_error(E_WARNING, "Unsupported content type: '%s'", content_type);
return; return;
} }
SG(request_info).post_entry = NULL;
} }
if (oldchar) { if (oldchar) {
*(p-1) = oldchar; *(p-1) = oldchar;
Expand Down
21 changes: 17 additions & 4 deletions main/php_content_types.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,12 +37,25 @@ static sapi_post_entry php_post_entries[] = {
*/ */
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader) SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
{ {
char *data; char *data = NULL;


if(PG(always_populate_raw_post_data)) { if(PG(always_populate_raw_post_data)) {
if(!SG(request_info).post_data) sapi_read_standard_form_data(TSRMLS_C); if(NULL == SG(request_info).post_data) { /* no data yet */
data = estrndup(SG(request_info).post_data, SG(request_info).post_data_length); if(NULL == SG(request_info).post_entry) {
SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, SG(request_info).post_data_length); /* 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);
}
} }
} }
/* }}} */ /* }}} */
Expand Down

0 comments on commit 5aec6f4

Please sign in to comment.