]> granicus.if.org Git - php/commitdiff
MFB input filter hook for getenv()
authorRasmus Lerdorf <rasmus@php.net>
Wed, 10 May 2006 21:25:01 +0000 (21:25 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Wed, 10 May 2006 21:25:01 +0000 (21:25 +0000)
main/SAPI.c
sapi/apache/mod_php5.c

index d2e8c8ec807aa008dcd159a2484d97fbdcec3e4e..4a5ea83521c109743a1123c15e443bc00be79f43 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "php.h"
 #include "SAPI.h"
+#include "php_variables.h"
 #include "php_ini.h"
 #include "ext/standard/php_string.h"
 #include "ext/standard/pageinfo.h"
@@ -876,11 +877,15 @@ SAPI_API struct stat *sapi_get_stat(TSRMLS_D)
 
 SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC)
 {
-       if (sapi_module.getenv) {
-               return sapi_module.getenv(name, name_len TSRMLS_CC);
+       if (sapi_module.getenv) { 
+               char *value, *tmp = sapi_module.getenv(name, name_len TSRMLS_CC);
+               if(tmp) value = estrdup(tmp); 
+               else return NULL;
+               sapi_module.input_filter(PARSE_ENV, name, &value, strlen(value), NULL TSRMLS_CC);
+               return value;
        } else {
-               return NULL;
-       }
+               return NULL; 
+       }   
 }
 
 SAPI_API int sapi_get_fd(int *fd TSRMLS_DC)
index ed1434b1464a2b0561d5e072dc9cc002e37d43ba..925a0b6cf0150d52a34fac7f9b9d385f03e6fc3a 100644 (file)
@@ -250,13 +250,17 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_
 
        for (i = 0; i < arr->nelts; i++) {
                char *val;
+               int val_len, new_val_len;
 
                if (elts[i].val) {
                        val = elts[i].val;
                } else {
                        val = "";
                }
-               php_register_variable(elts[i].key, val, track_vars_array  TSRMLS_CC);
+               val_len = strlen(val);
+               if (sapi_module.input_filter(PARSE_SERVER, elts[i].key, &val, val_len, &new_val_len TSRMLS_CC)) {
+                       php_register_variable_safe(elts[i].key, val, new_val_len, track_vars_array TSRMLS_CC);
+               }
        }
 
        /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */