summaryrefslogtreecommitdiff
path: root/main/php_variables.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-02-01 21:25:15 +0100
committerOndřej Surý <ondrej@sury.org>2012-02-01 21:25:15 +0100
commit96fb2ff5760132a915766f1d9ec7c63001feacd8 (patch)
tree160904a89a8f3522fa4e47632db101b045e7814a /main/php_variables.c
parent8f1428d29ef91d74b4d272af171675f2971eb15b (diff)
downloadphp-96fb2ff5760132a915766f1d9ec7c63001feacd8.tar.gz
Imported Upstream version 5.4.0~rc6upstream/5.4.0_rc6
Diffstat (limited to 'main/php_variables.c')
-rw-r--r--main/php_variables.c313
1 files changed, 133 insertions, 180 deletions
diff --git a/main/php_variables.c b/main/php_variables.c
index 8a84ac870..8a9b09485 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_variables.c 321634 2012-01-01 13:15:04Z felipe $ */
+/* $Id: php_variables.c 321828 2012-01-06 13:38:06Z patrickallaert $ */
#include <stdio.h>
#include "php.h"
@@ -47,11 +47,7 @@ PHPAPI void php_register_variable_safe(char *var, char *strval, int str_len, zva
/* Prepare value */
Z_STRLEN(new_entry) = str_len;
- if (PG(magic_quotes_gpc)) {
- Z_STRVAL(new_entry) = php_addslashes(strval, Z_STRLEN(new_entry), &Z_STRLEN(new_entry), 0 TSRMLS_CC);
- } else {
- Z_STRVAL(new_entry) = estrndup(strval, Z_STRLEN(new_entry));
- }
+ Z_STRVAL(new_entry) = estrndup(strval, Z_STRLEN(new_entry));
Z_TYPE(new_entry) = IS_STRING;
php_register_variable_ex(var, &new_entry, track_vars_array TSRMLS_CC);
@@ -67,33 +63,32 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
zval *gpc_element, **gpc_element_p;
zend_bool is_array = 0;
HashTable *symtable1 = NULL;
+ ALLOCA_FLAG(use_heap)
assert(var_name != NULL);
if (track_vars_array) {
symtable1 = Z_ARRVAL_P(track_vars_array);
- } else if (PG(register_globals)) {
- if (!EG(active_symbol_table)) {
- zend_rebuild_symbol_table(TSRMLS_C);
- }
- symtable1 = EG(active_symbol_table);
}
+
if (!symtable1) {
/* Nothing to do */
zval_dtor(val);
return;
}
- /*
- * Prepare variable name
- */
- var_orig = estrdup(var_name);
- var = var_orig;
/* ignore leading spaces in the variable name */
- while (*var && *var==' ') {
- var++;
+ while (*var_name && *var_name==' ') {
+ var_name++;
}
+
+ /*
+ * Prepare variable name
+ */
+ var_len = strlen(var_name);
+ var = var_orig = do_alloca(var_len + 1, use_heap);
+ memcpy(var_orig, var_name, var_len + 1);
/* ensure that we don't have spaces or dots in the variable name (not binary safe) */
for (p = var; *p; p++) {
@@ -110,7 +105,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
if (var_len==0) { /* empty variable name, or variable name with a space in it */
zval_dtor(val);
- efree(var_orig);
+ free_alloca(var_orig, use_heap);
return;
}
@@ -119,7 +114,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
var_len == sizeof("GLOBALS")-1 &&
!memcmp(var, "GLOBALS", sizeof("GLOBALS")-1)) {
zval_dtor(val);
- efree(var_orig);
+ free_alloca(var_orig, use_heap);
return;
}
@@ -139,9 +134,6 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
if (track_vars_array) {
ht = Z_ARRVAL_P(track_vars_array);
zend_hash_del(ht, var, var_len + 1);
- } else if (PG(register_globals)) {
- ht = EG(active_symbol_table);
- zend_hash_del(ht, var, var_len + 1);
}
zval_dtor(val);
@@ -151,7 +143,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
if (!PG(display_errors)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variable nesting level exceeded %ld. To increase the limit change max_input_nesting_level in php.ini.", PG(max_input_nesting_level));
}
- efree(var_orig);
+ free_alloca(var_orig, use_heap);
return;
}
@@ -184,11 +176,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
array_init(gpc_element);
zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
} else {
- if (PG(magic_quotes_gpc)) {
- escaped_index = php_addslashes(index, index_len, &index_len, 0 TSRMLS_CC);
- } else {
- escaped_index = index;
- }
+ escaped_index = index;
if (zend_symtable_find(symtable1, escaped_index, index_len + 1, (void **) &gpc_element_p) == FAILURE
|| Z_TYPE_PP(gpc_element_p) != IS_ARRAY) {
if (zend_hash_num_elements(symtable1) <= PG(max_input_vars)) {
@@ -225,11 +213,7 @@ plain_var:
if (!index) {
zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
} else {
- if (PG(magic_quotes_gpc)) {
- escaped_index = php_addslashes(index, index_len, &index_len, 0 TSRMLS_CC);
- } else {
- escaped_index = index;
- }
+ escaped_index = index;
/*
* According to rfc2965, more specific paths are listed above the less specific ones.
* If we encounter a duplicate cookie name, we should skip it, since it is not possible
@@ -255,7 +239,7 @@ plain_var:
}
}
}
- efree(var_orig);
+ free_alloca(var_orig, use_heap);
}
SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
@@ -441,10 +425,6 @@ void _php_import_environment_variables(zval *array_ptr TSRMLS_DC)
size_t alloc_size = sizeof(buf);
unsigned long nlen; /* ptrdiff_t is not portable */
- /* turn off magic_quotes while importing environment variables */
- int magic_quotes_gpc = PG(magic_quotes_gpc);
- PG(magic_quotes_gpc) = 0;
-
for (env = environ; env != NULL && *env != NULL; env++) {
p = strchr(*env, '=');
if (!p) { /* malformed entry? */
@@ -462,7 +442,6 @@ void _php_import_environment_variables(zval *array_ptr TSRMLS_DC)
if (t != buf && t != NULL) {
efree(t);
}
- PG(magic_quotes_gpc) = magic_quotes_gpc;
}
zend_bool php_std_auto_global_callback(char *name, uint name_len TSRMLS_DC)
@@ -479,7 +458,7 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
int count = 0;
char *ss, *space;
- if (!(PG(register_globals) || SG(request_info).argc || track_vars_array)) {
+ if (!(SG(request_info).argc || track_vars_array)) {
return;
}
@@ -538,7 +517,7 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
}
Z_TYPE_P(argc) = IS_LONG;
- if (PG(register_globals) || SG(request_info).argc) {
+ if (SG(request_info).argc) {
Z_ADDREF_P(arr);
Z_ADDREF_P(argc);
zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL);
@@ -576,8 +555,6 @@ PHPAPI int php_handle_special_queries(TSRMLS_D)
static inline void php_register_server_variables(TSRMLS_D)
{
zval *array_ptr = NULL;
- /* turn off magic_quotes while importing server variables */
- int magic_quotes_gpc = PG(magic_quotes_gpc);
ALLOC_ZVAL(array_ptr);
array_init(array_ptr);
@@ -586,7 +563,6 @@ 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;
/* Server variables */
if (sapi_module.register_server_variables) {
@@ -605,13 +581,15 @@ static inline void php_register_server_variables(TSRMLS_D)
}
/* store request init time */
{
- zval new_entry;
- Z_TYPE(new_entry) = IS_LONG;
- Z_LVAL(new_entry) = sapi_get_request_time(TSRMLS_C);
- php_register_variable_ex("REQUEST_TIME", &new_entry, array_ptr TSRMLS_CC);
+ zval request_time_float, request_time_long;
+ Z_TYPE(request_time_float) = IS_DOUBLE;
+ Z_DVAL(request_time_float) = sapi_get_request_time(TSRMLS_C);
+ php_register_variable_ex("REQUEST_TIME_FLOAT", &request_time_float, array_ptr TSRMLS_CC);
+ Z_TYPE(request_time_long) = IS_LONG;
+ Z_LVAL(request_time_long) = zend_dval_to_lval(Z_DVAL(request_time_float));
+ php_register_variable_ex("REQUEST_TIME", &request_time_long, array_ptr TSRMLS_CC);
}
- PG(magic_quotes_gpc) = magic_quotes_gpc;
}
/* }}} */
@@ -625,7 +603,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC)
ulong num_key;
HashPosition pos;
int key_type;
- int globals_check = (PG(register_globals) && (dest == (&EG(symbol_table))));
+ int globals_check = (dest == (&EG(symbol_table)));
zend_hash_internal_pointer_reset_ex(src, &pos);
while (zend_hash_get_current_data_ex(src, (void **)&src_entry, &pos) == SUCCESS) {
@@ -634,10 +612,9 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC)
|| (key_type == HASH_KEY_IS_STRING && zend_hash_find(dest, string_key, string_key_len, (void **) &dest_entry) != SUCCESS)
|| (key_type == HASH_KEY_IS_LONG && zend_hash_index_find(dest, num_key, (void **)&dest_entry) != SUCCESS)
|| Z_TYPE_PP(dest_entry) != IS_ARRAY
- ) {
+ ) {
Z_ADDREF_PP(src_entry);
if (key_type == HASH_KEY_IS_STRING) {
- /* if register_globals is on and working with main symbol table, prevent overwriting of GLOBALS */
if (!globals_check || string_key_len != sizeof("GLOBALS") || memcmp(string_key, "GLOBALS", sizeof("GLOBALS") - 1)) {
zend_hash_update(dest, string_key, string_key_len, src_entry, sizeof(zval *), NULL);
} else {
@@ -655,130 +632,116 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC)
}
/* }}} */
-static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS_DC);
-static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC);
-static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRMLS_DC);
+static zend_bool php_auto_globals_create_server(const char *name, uint name_len TSRMLS_DC);
+static zend_bool php_auto_globals_create_env(const char *name, uint name_len TSRMLS_DC);
+static zend_bool php_auto_globals_create_request(const char *name, uint name_len TSRMLS_DC);
/* {{{ php_hash_environment
*/
int php_hash_environment(TSRMLS_D)
{
- char *p;
- unsigned char _gpc_flags[5] = {0, 0, 0, 0, 0};
- zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays));
- struct auto_global_record {
- char *name;
- uint name_len;
- char *long_name;
- uint long_name_len;
- zend_bool jit_initialization;
- } auto_global_records[] = {
- { "_POST", sizeof("_POST"), "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"), 0 },
- { "_GET", sizeof("_GET"), "HTTP_GET_VARS", sizeof("HTTP_GET_VARS"), 0 },
- { "_COOKIE", sizeof("_COOKIE"), "HTTP_COOKIE_VARS", sizeof("HTTP_COOKIE_VARS"), 0 },
- { "_SERVER", sizeof("_SERVER"), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), 1 },
- { "_ENV", sizeof("_ENV"), "HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS"), 1 },
- { "_FILES", sizeof("_FILES"), "HTTP_POST_FILES", sizeof("HTTP_POST_FILES"), 0 },
- };
- size_t num_track_vars = sizeof(auto_global_records)/sizeof(struct auto_global_record);
- size_t i;
-
- /* jit_initialization = 0; */
- for (i=0; i<num_track_vars; i++) {
- PG(http_globals)[i] = NULL;
- }
-
- for (p=PG(variables_order); p && *p; p++) {
- switch(*p) {
- case 'p':
- case 'P':
- if (!_gpc_flags[0] && !SG(headers_sent) && SG(request_info).request_method && !strcasecmp(SG(request_info).request_method, "POST")) {
- sapi_module.treat_data(PARSE_POST, NULL, NULL TSRMLS_CC); /* POST Data */
- _gpc_flags[0] = 1;
- if (PG(register_globals)) {
- php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_POST]) TSRMLS_CC);
- }
- }
- break;
- case 'c':
- case 'C':
- if (!_gpc_flags[1]) {
- sapi_module.treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC); /* Cookie Data */
- _gpc_flags[1] = 1;
- if (PG(register_globals)) {
- php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]) TSRMLS_CC);
- }
- }
- break;
- case 'g':
- case 'G':
- if (!_gpc_flags[2]) {
- sapi_module.treat_data(PARSE_GET, NULL, NULL TSRMLS_CC); /* GET Data */
- _gpc_flags[2] = 1;
- if (PG(register_globals)) {
- php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_GET]) TSRMLS_CC);
- }
- }
- break;
- case 'e':
- case 'E':
- if (!jit_initialization && !_gpc_flags[3]) {
- zend_auto_global_disable_jit("_ENV", sizeof("_ENV")-1 TSRMLS_CC);
- php_auto_globals_create_env("_ENV", sizeof("_ENV")-1 TSRMLS_CC);
- _gpc_flags[3] = 1;
- if (PG(register_globals)) {
- php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV]) TSRMLS_CC);
- }
- }
- break;
- case 's':
- case 'S':
- if (!jit_initialization && !_gpc_flags[4]) {
- zend_auto_global_disable_jit("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
- php_register_server_variables(TSRMLS_C);
- _gpc_flags[4] = 1;
- if (PG(register_globals)) {
- php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]) TSRMLS_CC);
- }
- }
- break;
- }
- }
-
- /* argv/argc support */
+ memset(PG(http_globals), 0, sizeof(PG(http_globals)));
+ zend_activate_auto_globals(TSRMLS_C);
if (PG(register_argc_argv)) {
php_build_argv(SG(request_info).query_string, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
}
+ return SUCCESS;
+}
+/* }}} */
- for (i=0; i<num_track_vars; i++) {
- if (jit_initialization && auto_global_records[i].jit_initialization) {
- continue;
+static zend_bool php_auto_globals_create_get(const char *name, uint name_len TSRMLS_DC)
+{
+ zval *vars;
+
+ if (PG(variables_order) && (strchr(PG(variables_order),'G') || strchr(PG(variables_order),'g'))) {
+ sapi_module.treat_data(PARSE_GET, NULL, NULL TSRMLS_CC);
+ vars = PG(http_globals)[TRACK_VARS_GET];
+ } else {
+ ALLOC_ZVAL(vars);
+ array_init(vars);
+ INIT_PZVAL(vars);
+ if (PG(http_globals)[TRACK_VARS_GET]) {
+ zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_GET]);
}
- if (!PG(http_globals)[i]) {
- ALLOC_ZVAL(PG(http_globals)[i]);
- array_init(PG(http_globals)[i]);
- INIT_PZVAL(PG(http_globals)[i]);
+ PG(http_globals)[TRACK_VARS_GET] = vars;
+ }
+
+ zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL);
+ Z_ADDREF_P(vars);
+
+ return 0; /* don't rearm */
+}
+
+static zend_bool php_auto_globals_create_post(const char *name, uint name_len TSRMLS_DC)
+{
+ zval *vars;
+
+ if (PG(variables_order) &&
+ (strchr(PG(variables_order),'P') || strchr(PG(variables_order),'p')) &&
+ !SG(headers_sent) &&
+ SG(request_info).request_method &&
+ !strcasecmp(SG(request_info).request_method, "POST")) {
+ sapi_module.treat_data(PARSE_POST, NULL, NULL TSRMLS_CC);
+ vars = PG(http_globals)[TRACK_VARS_POST];
+ } else {
+ ALLOC_ZVAL(vars);
+ array_init(vars);
+ INIT_PZVAL(vars);
+ if (PG(http_globals)[TRACK_VARS_POST]) {
+ zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_POST]);
}
+ PG(http_globals)[TRACK_VARS_POST] = vars;
+ }
- Z_ADDREF_P(PG(http_globals)[i]);
- zend_hash_update(&EG(symbol_table), auto_global_records[i].name, auto_global_records[i].name_len, &PG(http_globals)[i], sizeof(zval *), NULL);
- if (PG(register_long_arrays)) {
- zend_hash_update(&EG(symbol_table), auto_global_records[i].long_name, auto_global_records[i].long_name_len, &PG(http_globals)[i], sizeof(zval *), NULL);
- Z_ADDREF_P(PG(http_globals)[i]);
+ zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL);
+ Z_ADDREF_P(vars);
+
+ return 0; /* don't rearm */
+}
+
+static zend_bool php_auto_globals_create_cookie(const char *name, uint name_len TSRMLS_DC)
+{
+ zval *vars;
+
+ if (PG(variables_order) && (strchr(PG(variables_order),'C') || strchr(PG(variables_order),'c'))) {
+ sapi_module.treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC);
+ vars = PG(http_globals)[TRACK_VARS_COOKIE];
+ } else {
+ ALLOC_ZVAL(vars);
+ array_init(vars);
+ INIT_PZVAL(vars);
+ if (PG(http_globals)[TRACK_VARS_COOKIE]) {
+ zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_COOKIE]);
}
+ PG(http_globals)[TRACK_VARS_COOKIE] = vars;
}
- /* Create _REQUEST */
- if (!jit_initialization) {
- zend_auto_global_disable_jit("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC);
- php_auto_globals_create_request("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC);
+ zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL);
+ Z_ADDREF_P(vars);
+
+ return 0; /* don't rearm */
+}
+
+static zend_bool php_auto_globals_create_files(const char *name, uint name_len TSRMLS_DC)
+{
+ zval *vars;
+
+ if (PG(http_globals)[TRACK_VARS_FILES]) {
+ vars = PG(http_globals)[TRACK_VARS_FILES];
+ } else {
+ ALLOC_ZVAL(vars);
+ array_init(vars);
+ INIT_PZVAL(vars);
+ PG(http_globals)[TRACK_VARS_FILES] = vars;
}
- return SUCCESS;
+ zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL);
+ Z_ADDREF_P(vars);
+
+ return 0; /* don't rearm */
}
-/* }}} */
-static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS_DC)
+static zend_bool php_auto_globals_create_server(const char *name, uint name_len TSRMLS_DC)
{
if (PG(variables_order) && (strchr(PG(variables_order),'S') || strchr(PG(variables_order),'s'))) {
php_register_server_variables(TSRMLS_C);
@@ -788,7 +751,7 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS
zval **argc, **argv;
if (zend_hash_find(&EG(symbol_table), "argc", sizeof("argc"), (void**)&argc) == SUCCESS &&
- zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) {
+ zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) {
Z_ADDREF_PP(argc);
Z_ADDREF_PP(argv);
zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), argv, sizeof(zval *), NULL);
@@ -812,16 +775,11 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS
zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL);
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]);
-
- if (PG(register_long_arrays)) {
- zend_hash_update(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL);
- Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]);
- }
return 0; /* don't rearm */
}
-static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC)
+static zend_bool php_auto_globals_create_env(const char *name, uint name_len TSRMLS_DC)
{
zval *env_vars = NULL;
ALLOC_ZVAL(env_vars);
@@ -839,15 +797,10 @@ static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC
zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL);
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]);
- if (PG(register_long_arrays)) {
- zend_hash_update(&EG(symbol_table), "HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS"), &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL);
- Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]);
- }
-
return 0; /* don't rearm */
}
-static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRMLS_DC)
+static zend_bool php_auto_globals_create_request(const char *name, uint name_len TSRMLS_DC)
{
zval *form_variables;
unsigned char _gpc_flags[3] = {0, 0, 0};
@@ -857,7 +810,7 @@ static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRML
array_init(form_variables);
INIT_PZVAL(form_variables);
- if(PG(request_order) != NULL) {
+ if (PG(request_order) != NULL) {
p = PG(request_order);
} else {
p = PG(variables_order);
@@ -889,19 +842,19 @@ static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRML
}
}
- zend_hash_update(&EG(symbol_table), "_REQUEST", sizeof("_REQUEST"), &form_variables, sizeof(zval *), NULL);
+ zend_hash_update(&EG(symbol_table), name, name_len + 1, &form_variables, sizeof(zval *), NULL);
return 0;
}
void php_startup_auto_globals(TSRMLS_D)
{
- zend_register_auto_global("_GET", sizeof("_GET")-1, NULL TSRMLS_CC);
- zend_register_auto_global("_POST", sizeof("_POST")-1, NULL TSRMLS_CC);
- zend_register_auto_global("_COOKIE", sizeof("_COOKIE")-1, NULL TSRMLS_CC);
- zend_register_auto_global("_SERVER", sizeof("_SERVER")-1, php_auto_globals_create_server TSRMLS_CC);
- zend_register_auto_global("_ENV", sizeof("_ENV")-1, php_auto_globals_create_env TSRMLS_CC);
- zend_register_auto_global("_REQUEST", sizeof("_REQUEST")-1, php_auto_globals_create_request TSRMLS_CC);
- zend_register_auto_global("_FILES", sizeof("_FILES")-1, NULL TSRMLS_CC);
+ zend_register_auto_global(ZEND_STRL("_GET"), 0, php_auto_globals_create_get TSRMLS_CC);
+ zend_register_auto_global(ZEND_STRL("_POST"), 0, php_auto_globals_create_post TSRMLS_CC);
+ zend_register_auto_global(ZEND_STRL("_COOKIE"), 0, php_auto_globals_create_cookie TSRMLS_CC);
+ zend_register_auto_global(ZEND_STRL("_SERVER"), PG(auto_globals_jit), php_auto_globals_create_server TSRMLS_CC);
+ zend_register_auto_global(ZEND_STRL("_ENV"), PG(auto_globals_jit), php_auto_globals_create_env TSRMLS_CC);
+ zend_register_auto_global(ZEND_STRL("_REQUEST"), PG(auto_globals_jit), php_auto_globals_create_request TSRMLS_CC);
+ zend_register_auto_global(ZEND_STRL("_FILES"), 0, php_auto_globals_create_files TSRMLS_CC);
}
/*