]> granicus.if.org Git - php/commitdiff
Add input_filter hook call in getenv()
authorRasmus Lerdorf <rasmus@php.net>
Wed, 10 May 2006 21:19:32 +0000 (21:19 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Wed, 10 May 2006 21:19:32 +0000 (21:19 +0000)
NEWS
main/SAPI.c
sapi/apache/mod_php5.c

diff --git a/NEWS b/NEWS
index da0080abb7fa45eb9b3a88f909c518b844e992a6..3dbb1c3861d5ccf0e251c023bc8eee65af87d8ab 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2006, PHP 5.2.0
+- Added support for getenv() input filtering. (Rasmus)
 - Removed ze1 compatibility mode. (Marcus)
 - Added support for constructors in interfaces to force constructor signature
   checks in implementations. (Marcus)
index 1eb457a42c84ebe1c6fd9e99ff586fb22378d37e..5bd12b13e96a608eac7bcb14ec105822ef0d7a73 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"
@@ -914,11 +915,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 be82e1336933e111aaf4639ba0b84413197b514f..04f9da4d8616c76018ed9b52e9f63404cdaf4f0c 100644 (file)
@@ -254,13 +254,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 */