From: foobar Date: Fri, 4 Feb 2005 10:41:02 +0000 (+0000) Subject: MFH: - Fixed bug #28227 (PHP CGI depends upon non-standard SCRIPT_FILENAME) X-Git-Tag: php-5.0.4RC1~201 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8cbe865f3e1a579c6213cbef30d479e8c0a90de;p=php MFH: - Fixed bug #28227 (PHP CGI depends upon non-standard SCRIPT_FILENAME) # Patch by: lukem at NetBSD dot org --- diff --git a/NEWS b/NEWS index 587e18b882..1877dd1a63 100644 --- 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) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index f06ac1a643..bd0bfebac7 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -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);