]> granicus.if.org Git - php/commitdiff
MFH: - Fixed bug #28227 (PHP CGI depends upon non-standard SCRIPT_FILENAME)
authorfoobar <sniper@php.net>
Fri, 4 Feb 2005 10:41:02 +0000 (10:41 +0000)
committerfoobar <sniper@php.net>
Fri, 4 Feb 2005 10:41:02 +0000 (10:41 +0000)
# Patch by: lukem at NetBSD dot org

NEWS
sapi/cgi/cgi_main.c

diff --git a/NEWS b/NEWS
index 587e18b882f906a752ba415a3c276e5ec976f811..1877dd1a633a2502ce90d953ce3cb444e9a55337 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -95,6 +95,8 @@ PHP                                                                        NEWS
   entries). (Andrei)
 - Fixed bug #28444 (Cannot access undefined property for object with overloaded
   property access). (Dmitry)
+- Fixed bug #28227 (PHP CGI depends upon non-standard SCRIPT_FILENAME). 
+  (lukem at NetBSD dot org)
 - Fixed bug #28074 (FastCGI: stderr should be written in a FCGI stderr stream).
   (chris at ex-parrot dot com)
 - Fixed bug #28041 (SOAP HTTP Digest Access Authentication). (Dmitry)
index f06ac1a643190f0bbcf75aa8b0a537d9ba79bac9..bd0bfebac741ccfab4ee57af3fcecddca3f0fd77 100644 (file)
@@ -661,8 +661,19 @@ static void init_request_info(TSRMLS_D)
 {
        char *env_script_filename = sapi_cgibin_getenv("SCRIPT_FILENAME",0 TSRMLS_CC);
        char *env_path_translated = sapi_cgibin_getenv("PATH_TRANSLATED",0 TSRMLS_CC);
+       char *env_script_name = sapi_cgibin_getenv("SCRIPT_NAME", 0 TSRMLS_CC);
        char *script_path_translated = env_script_filename;
 
+       /*
+        * CGI/1.1, as documented at: http://cgi-spec.golux.com/
+        * mentions SCRIPT_NAME but not SCRIPT_FILENAME.
+        */
+       if (!script_path_translated && env_script_name && *env_script_name == '/')  {
+               env_script_filename = _sapi_cgibin_putenv("SCRIPT_FILENAME",(env_script_name + 1) TSRMLS_CC);
+
+               script_path_translated = env_script_filename;
+       }
+
 #if !DISCARD_PATH
        /* some broken servers do not have script_filename or argv0
           an example, IIS configured in some ways.  then they do more
@@ -690,7 +701,6 @@ static void init_request_info(TSRMLS_D)
                char *content_length = sapi_cgibin_getenv("CONTENT_LENGTH",0 TSRMLS_CC);
                char *content_type = sapi_cgibin_getenv("CONTENT_TYPE",0 TSRMLS_CC);
                char *env_path_info = sapi_cgibin_getenv("PATH_INFO",0 TSRMLS_CC);
-               char *env_script_name = sapi_cgibin_getenv("SCRIPT_NAME",0 TSRMLS_CC);
 #if ENABLE_PATHINFO_CHECK
                struct stat st;
                char *env_redirect_url = sapi_cgibin_getenv("REDIRECT_URL",0 TSRMLS_CC);