Browse Source

Close [PHP-BUG] Req #54152...

Apache 2.3.12 (and later) will now work correctly with PHP's fcgi
impl with this patch.
experimental/with_scalar_types
Jim Jagielski 16 years ago
parent
commit
24126fa2df
  1. 41
      sapi/fpm/fpm/fpm_main.c

41
sapi/fpm/fpm/fpm_main.c

@ -1083,6 +1083,7 @@ static void init_request_info(TSRMLS_D)
char *env_path_translated = sapi_cgibin_getenv("PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1 TSRMLS_CC);
char *script_path_translated = env_script_filename;
char *ini;
int apache_was_here = 0;
/* some broken servers do not have script_filename or argv0
* an example, IIS configured in some ways. then they do more
@ -1128,6 +1129,30 @@ static void init_request_info(TSRMLS_D)
env_path_info = _sapi_cgibin_putenv("PATH_INFO", env_path_info TSRMLS_CC);
}
#define APACHE_PROXY_FCGI_PREFIX "proxy:fcgi://"
/* Fix proxy URLs in SCRIPT_FILENAME generated by Apache mod_proxy_fcgi:
* proxy:fcgi://localhost:9000/some-dir/info.php/test
* should be changed to:
* /some-dir/info.php/test
* See: http://bugs.php.net/bug.php?id=54152
* https://issues.apache.org/bugzilla/show_bug.cgi?id=50851
*/
if (env_script_filename &&
strncasecmp(env_script_filename, APACHE_PROXY_FCGI_PREFIX, sizeof(APACHE_PROXY_FCGI_PREFIX) - 1) == 0) {
/* advance to first character of hostname */
char *p = env_script_filename + (sizeof(APACHE_PROXY_FCGI_PREFIX) - 1);
while (*p != '\0' && *p != '/') {
p++; /* move past hostname and port */
}
if (*p != '\0') {
/* Copy path portion in place to avoid memory leak. Note
* that this also affects what script_path_translated points
* to. */
memmove(env_script_filename, p, strlen(p) + 1);
apache_was_here = 1;
}
}
if (CGIG(fix_pathinfo)) {
struct stat st;
char *real_path = NULL;
@ -1199,11 +1224,21 @@ static void init_request_info(TSRMLS_D)
* we have to play the game of hide and seek to figure
* out what SCRIPT_NAME should be
*/
int slen = len - strlen(pt);
int ptlen = strlen(pt);
int slen = len - ptlen;
int pilen = env_path_info ? strlen(env_path_info) : 0;
char *path_info = env_path_info ? env_path_info + pilen - slen : NULL;
int tflag = 0;
char *path_info;
if (apache_was_here) {
/* recall that PATH_INFO won't exist */
path_info = script_path_translated + ptlen;
tflag = (slen != 0 && (!orig_path_info || strcmp(orig_path_info, path_info) != 0));
} else {
path_info = env_path_info ? env_path_info + pilen - slen : NULL;
tflag = (orig_path_info != path_info);
}
if (orig_path_info != path_info) {
if (tflag) {
if (orig_path_info) {
char old;

Loading…
Cancel
Save