Always restore PG(magic_quote_gpc) on request shutdown

This commit is contained in:
Dmitry Stogov 2012-02-02 12:58:54 +00:00
parent 89bc5ece51
commit 87c038be06
3 changed files with 13 additions and 4 deletions

View File

@ -457,7 +457,10 @@ void _php_import_environment_variables(zval *array_ptr TSRMLS_DC)
/* turn off magic_quotes while importing environment variables */
int magic_quotes_gpc = PG(magic_quotes_gpc);
PG(magic_quotes_gpc) = 0;
if (PG(magic_quotes_gpc)) {
zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
}
for (env = environ; env != NULL && *env != NULL; env++) {
p = strchr(*env, '=');
@ -600,7 +603,9 @@ static inline void php_register_server_variables(TSRMLS_D)
zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]);
}
PG(http_globals)[TRACK_VARS_SERVER] = array_ptr;
PG(magic_quotes_gpc) = 0;
if (PG(magic_quotes_gpc)) {
zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
}
/* Server variables */
if (sapi_module.register_server_variables) {

View File

@ -624,7 +624,9 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
int filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER;
/* turn off magic_quotes while importing environment variables */
PG(magic_quotes_gpc) = 0;
if (PG(magic_quotes_gpc)) {
zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
}
for (zend_hash_internal_pointer_reset_ex(request->env, &pos);
zend_hash_get_current_key_ex(request->env, &var, &var_len, &idx, 0, &pos) == HASH_KEY_IS_STRING &&
zend_hash_get_current_data_ex(request->env, (void **) &val, &pos) == SUCCESS;

View File

@ -595,7 +595,9 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER;
/* turn off magic_quotes while importing environment variables */
PG(magic_quotes_gpc) = 0;
if (PG(magic_quotes_gpc)) {
zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
}
for (zend_hash_internal_pointer_reset_ex(request->env, &pos);
zend_hash_get_current_key_ex(request->env, &var, &var_len, &idx, 0, &pos) == HASH_KEY_IS_STRING &&
zend_hash_get_current_data_ex(request->env, (void **) &val, &pos) == SUCCESS;