dmitry          Mon Sep 24 11:40:06 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src    NEWS 
    /php-src/sapi/cgi   cgi_main.c 
  Log:
  Fixed bug #42699 (PHP_SELF duplicates path)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.961&r2=1.2027.2.547.2.962&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.961 php-src/NEWS:1.2027.2.547.2.962
--- php-src/NEWS:1.2027.2.547.2.961     Sun Sep 23 15:19:21 2007
+++ php-src/NEWS        Mon Sep 24 11:40:05 2007
@@ -32,6 +32,7 @@
 
 - Fixed bug #42739 (mkdir() doesnt like a trailing slash when safe_mode is 
   enabled). (Ilia)
+- Fixed bug #42699 (PHP_SELF duplicates path). (Dmitry)
 - Fixed bug #42643 (CLI segfaults if using ATTR_PERSISTENT). (Ilia)
 - Fixed bug #42629 (Dynamically loaded PHP extensions need symbols exported
   on MacOSX). (jdolecek at NetBSD dot org)
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.49&r2=1.267.2.15.2.50&diff_format=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.49 
php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50
--- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.49 Mon Sep 10 10:55:26 2007
+++ php-src/sapi/cgi/cgi_main.c Mon Sep 24 11:40:05 2007
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cgi_main.c,v 1.267.2.15.2.49 2007/09/10 10:55:26 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.267.2.15.2.50 2007/09/24 11:40:05 dmitry Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -522,29 +522,44 @@
 
 static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC)
 {
-       char *script_name   = SG(request_info).request_uri;
-       unsigned int script_name_len = script_name ? strlen(script_name) : 0;
-       char *path_info     = sapi_cgibin_getenv("PATH_INFO", 
sizeof("PATH_INFO")-1 TSRMLS_CC);
-       unsigned int path_info_len = path_info ? strlen(path_info) : 0;
-       unsigned int php_self_len = script_name_len + path_info_len;
-       char *php_self = emalloc(php_self_len + 1);
-
-       if (script_name) {
-               memcpy(php_self, script_name, script_name_len + 1);
-       }
-       if (path_info) {
-               memcpy(php_self + script_name_len, path_info, path_info_len + 
1);
-       }
+       unsigned int php_self_len;
+       char *php_self;
 
        /* 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 CGI version */
+
+#if ENABLE_PATHINFO_CHECK
+       if (CGIG(fix_pathinfo)) {
+               char *script_name   = SG(request_info).request_uri;
+               unsigned int script_name_len = script_name ? 
strlen(script_name) : 0;
+               char *path_info     = sapi_cgibin_getenv("PATH_INFO", 
sizeof("PATH_INFO")-1 TSRMLS_CC);
+               unsigned int path_info_len = path_info ? strlen(path_info) : 0;
+
+               php_self_len = script_name_len + path_info_len;
+               php_self = emalloc(php_self_len + 1);
+               if (script_name) {
+                       memcpy(php_self, script_name, script_name_len + 1);
+               }
+               if (path_info) {
+                       memcpy(php_self + script_name_len, path_info, 
path_info_len + 1);
+               }
+
+               /* Build the special-case PHP_SELF variable for the CGI version 
*/
+               if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", 
&php_self, php_self_len, &php_self_len TSRMLS_CC)) {
+                       php_register_variable_safe("PHP_SELF", php_self, 
php_self_len, track_vars_array TSRMLS_CC);
+               }
+               efree(php_self);
+               return;
+       }
+#endif
+
+       php_self = SG(request_info).request_uri ? SG(request_info).request_uri 
: "";
+       php_self_len = strlen(php_self);
        if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &php_self, 
php_self_len, &php_self_len TSRMLS_CC)) {
                php_register_variable_safe("PHP_SELF", php_self, php_self_len, 
track_vars_array TSRMLS_CC);
        }
-       efree(php_self);
 }
 
 static void sapi_cgi_log_message(char *message)

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

Reply via email to