lbarnaud                Thu Jul 24 09:11:48 2008 UTC

  Added files:                 
    /php-src/ext/filter/tests   bug44779.phpt 

  Modified files:              
    /php-src/sapi/cli   php_cli.c 
  Log:
  Allow filters to work on INPUT_SERVER in CLI (bug #44779)
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.191&r2=1.192&diff_format=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.191 php-src/sapi/cli/php_cli.c:1.192
--- php-src/sapi/cli/php_cli.c:1.191    Wed Jul 23 11:24:35 2008
+++ php-src/sapi/cli/php_cli.c  Thu Jul 24 09:11:48 2008
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli.c,v 1.191 2008/07/23 11:24:35 tony2001 Exp $ */
+/* $Id: php_cli.c,v 1.192 2008/07/24 09:11:48 lbarnaud Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -296,19 +296,35 @@
 
 static void sapi_cli_register_variables(zval *track_vars_array TSRMLS_DC) /* 
{{{ */
 {
+       size_t len;
+       char   *docroot = "";
+
        /* In CGI mode, we consider the environment to be a part of the server
         * variables
         */
        php_import_environment_variables(track_vars_array TSRMLS_CC);
 
        /* Build the special-case PHP_SELF variable for the CLI version */
-       php_register_variable("PHP_SELF", php_self, track_vars_array TSRMLS_CC);
-       php_register_variable("SCRIPT_NAME", php_self, track_vars_array 
TSRMLS_CC);
+       len = strlen(php_self);
+       if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &php_self, len, 
&len TSRMLS_CC)) {
+               php_register_variable("PHP_SELF", php_self, track_vars_array 
TSRMLS_CC);
+       }
+       if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_NAME", &php_self, 
len, &len TSRMLS_CC)) {
+               php_register_variable("SCRIPT_NAME", php_self, track_vars_array 
TSRMLS_CC);
+       }
        /* filenames are empty for stdin */
-       php_register_variable("SCRIPT_FILENAME", script_filename, 
track_vars_array TSRMLS_CC);
-       php_register_variable("PATH_TRANSLATED", script_filename, 
track_vars_array TSRMLS_CC);
+       len = strlen(script_filename);
+       if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_FILENAME", 
&script_filename, len, &len TSRMLS_CC)) {
+               php_register_variable("SCRIPT_FILENAME", script_filename, 
track_vars_array TSRMLS_CC);
+       }
+       if (sapi_module.input_filter(PARSE_SERVER, "PATH_TRANSLATED", 
&script_filename, len, &len TSRMLS_CC)) {
+               php_register_variable("PATH_TRANSLATED", script_filename, 
track_vars_array TSRMLS_CC);
+       }
        /* just make it available */
-       php_register_variable("DOCUMENT_ROOT", "", track_vars_array TSRMLS_CC);
+       len = 0U;
+       if (sapi_module.input_filter(PARSE_SERVER, "DOCUMENT_ROOT", &docroot, 
len, &len TSRMLS_CC)) {
+               php_register_variable("DOCUMENT_ROOT", docroot, 
track_vars_array TSRMLS_CC);
+       }
 }
 /* }}} */
 

http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/bug44779.phpt?view=markup&rev=1.1
Index: php-src/ext/filter/tests/bug44779.phpt
+++ php-src/ext/filter/tests/bug44779.phpt
--TEST--
Bug #44779 (filter returns NULL in CLI when it shouldn't)
--FILE--
<?php
var_dump(filter_input(INPUT_SERVER, "PHP_SELF"));
?>
--EXPECTF--
%unicode|string%(%d) "%s"



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to