diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index b4613f1af6d2f90a8d93cd912cf279964dbbd750..2251eee59a0d120b51a6bb661cead6cb7f390b1b 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -758,7 +758,15 @@ class HTTP { $url = self::getSelfURLHost(); $url .= $_SERVER['SCRIPT_NAME']; - if (isset($_SERVER['PATH_INFO'])) { + + /* In some environments, $_SERVER['SCRIPT_NAME'] already ends with $_SERVER['PATH_INFO']. Only append + * $_SERVER['PATH_INFO'] if it's set and missing from script name. + * + * Contributed by Travis Hegner. + */ + if (isset($_SERVER['PATH_INFO']) && + $_SERVER['PATH_INFO'] !== substr($_SERVER['SCRIPT_NAME'], - strlen($_SERVER['PATH_INFO']))) + { $url .= $_SERVER['PATH_INFO']; } return $url; diff --git a/www/module.php b/www/module.php index 9c09c6582dbce68e266e03261c29f2b1e5b89c90..03409fe722e18fff864b0e513453b1759227c3c6 100644 --- a/www/module.php +++ b/www/module.php @@ -123,7 +123,17 @@ try { if (preg_match('#\.php$#D', $path)) { // PHP file - attempt to run it - $_SERVER['SCRIPT_NAME'] .= '/'.$module.'/'.$url; + + /* In some environments, $_SERVER['SCRIPT_NAME'] is already set with $_SERVER['PATH_INFO']. Check for that case, + * and append script name only if necessary. + * + * Contributed by Travis Hegner. + */ + $script = "/$module/$url"; + if (stripos($_SERVER['SCRIPT_NAME'], $script) === false) { + $_SERVER['SCRIPT_NAME'] .= '/'.$module.'/'.$url; + } + require($path); exit(); }