Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,6 @@ PHP_ADD_SOURCES([main], m4_normalize([
main.c
network.c
output.c
php_content_types.c
php_ini_builder.c
php_ini.c
php_glob.c
Expand Down
9 changes: 0 additions & 9 deletions ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

#include "php_globals.h"
#include "rfc1867.h"
#include "php_content_types.h"
#include "SAPI.h"
#include "php_unicode.h"
#include "TSRM.h"
Expand Down Expand Up @@ -208,14 +207,6 @@ zend_module_entry mbstring_module_entry = {
};
/* }}} */

/* {{{ static sapi_post_entry php_post_entries[] */
static const sapi_post_entry php_post_entries[] = {
{ DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data, php_std_post_handler },
{ MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL, rfc1867_post_handler },
{ NULL, 0, NULL, NULL }
};
/* }}} */

#ifdef COMPILE_DL_MBSTRING
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
Expand Down
36 changes: 13 additions & 23 deletions main/SAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

#include "rfc1867.h"

#include "php_content_types.h"

#ifdef ZTS
SAPI_API int sapi_globals_id;
SAPI_API size_t sapi_globals_offset;
Expand All @@ -51,7 +49,7 @@ static void sapi_globals_ctor(sapi_globals_struct *sapi_globals)
{
memset(sapi_globals, 0, sizeof(*sapi_globals));
zend_hash_init(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1);
php_setup_sapi_content_types();
sapi_register_post_entries(php_post_entries);
}

static void sapi_globals_dtor(sapi_globals_struct *sapi_globals)
Expand Down Expand Up @@ -177,13 +175,6 @@ SAPI_API void sapi_read_post_data(void)
} else {
/* fallback */
SG(request_info).post_entry = NULL;
if (UNEXPECTED(!sapi_module.default_post_reader)) {
/* this should not happen as there should always be a default_post_reader */
SG(request_info).content_type_dup = NULL;
sapi_module.sapi_error(E_WARNING, "Unsupported content type: '%s'", content_type);
efree(content_type);
return;
}
}
if (oldchar) {
*(p-1) = oldchar;
Expand All @@ -196,8 +187,11 @@ SAPI_API void sapi_read_post_data(void)
post_reader_func();
}

if(sapi_module.default_post_reader) {
sapi_module.default_post_reader();
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();
}
}
}

Expand Down Expand Up @@ -918,6 +912,13 @@ SAPI_API zend_result sapi_send_headers(void)
return ret;
}

/* {{{ php_post_entries[] */
const sapi_post_entry php_post_entries[] = {
{ DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data, php_std_post_handler },
{ MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL, rfc1867_post_handler },
{ NULL, 0, NULL, NULL }
};
/* }}} */

SAPI_API zend_result sapi_register_post_entries(const sapi_post_entry *post_entries)
{
Expand Down Expand Up @@ -956,17 +957,6 @@ SAPI_API void sapi_unregister_post_entry(const sapi_post_entry *post_entry)
post_entry->content_type_len);
}


SAPI_API zend_result sapi_register_default_post_reader(void (*default_post_reader)(void))
{
if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
}
sapi_module.default_post_reader = default_post_reader;
return SUCCESS;
}


SAPI_API zend_result sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray))
{
if (SG(sapi_started) && EG(current_execute_data)) {
Expand Down
12 changes: 8 additions & 4 deletions main/SAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ SAPI_API size_t sapi_read_post_block(char *buffer, size_t buflen);
SAPI_API zend_result sapi_register_post_entries(const sapi_post_entry *post_entry);
SAPI_API zend_result sapi_register_post_entry(const sapi_post_entry *post_entry);
SAPI_API void sapi_unregister_post_entry(const sapi_post_entry *post_entry);
SAPI_API zend_result sapi_register_default_post_reader(void (*default_post_reader)(void));
SAPI_API zend_result sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray));
SAPI_API zend_result sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));

Expand Down Expand Up @@ -257,7 +256,6 @@ struct _sapi_module_struct {

char *php_ini_path_override;

void (*default_post_reader)(void);
void (*treat_data)(int arg, char *str, zval *destArray);
char *executable_location;

Expand All @@ -283,6 +281,11 @@ struct _sapi_post_entry {
void (*post_handler)(char *content_type_dup, void *arg);
};

BEGIN_EXTERN_C()
/* Default POST entries to switch back to when overrode */
extern SAPI_API const sapi_post_entry php_post_entries[];
END_EXTERN_C()

/* header_handler() constants */
#define SAPI_HEADER_ADD (1<<0)

Expand All @@ -301,16 +304,17 @@ struct _sapi_post_entry {
#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray)
#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len)

#define DEFAULT_POST_CONTENT_TYPE "application/x-www-form-urlencoded"

BEGIN_EXTERN_C()
SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler);
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader);
SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data);
SAPI_API SAPI_INPUT_FILTER_FUNC(php_default_input_filter);
END_EXTERN_C()

#define STANDARD_SAPI_MODULE_PROPERTIES \
NULL, /* php_ini_path_override */ \
NULL, /* default_post_reader */ \
NULL, /* treat_data */ \
NULL, /* executable_location */ \
0, /* php_ini_ignore */ \
Expand Down
5 changes: 3 additions & 2 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
#include "zend_system_id.h"
#include "zend_smart_string.h"

#include "php_content_types.h"
#include "php_ticks.h"
#include "php_streams.h"
#include "php_open_temporary_file.h"
Expand Down Expand Up @@ -2275,7 +2274,9 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
zuv.html_errors = 1;
php_startup_auto_globals();
zend_set_utility_values(&zuv);
php_startup_sapi_content_types();

sapi_register_treat_data(php_default_treat_data);
sapi_register_input_filter(php_default_input_filter, NULL);

/* Begin to fingerprint the process state */
zend_startup_system_id();
Expand Down
56 changes: 0 additions & 56 deletions main/php_content_types.c

This file was deleted.

23 changes: 0 additions & 23 deletions main/php_content_types.h

This file was deleted.

1 change: 0 additions & 1 deletion main/php_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "zend_smart_str.h"
#include "php_variables.h"
#include "php_globals.h"
#include "php_content_types.h"
#include "SAPI.h"
#include "zend_globals.h"
#include "zend_exceptions.h"
Expand Down
2 changes: 1 addition & 1 deletion win32/build/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");

ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \
php_ini_builder.c php_glob.c \
php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
php_scandir.c php_ini.c SAPI.c rfc1867.c strlcpy.c \
strlcat.c reentrancy.c php_variables.c php_ticks.c network.c \
php_open_temporary_file.c output.c internal_functions.c \
php_syslog.c php_odbc_utils.c safe_bcmp.c");
Expand Down
Loading