ID: 41793 Updated by: [EMAIL PROTECTED] Reported By: chris at w3style dot co dot uk -Status: Open +Status: Feedback Bug Type: CGI related Operating System: Mac OS X PHP Version: 5.2.3 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows (zip): http://snaps.php.net/win32/php5.2-win32-latest.zip For Windows (installer): http://snaps.php.net/win32/php5.2-win32-installer-latest.msi I think something like this was fixed last week. Previous Comments: ------------------------------------------------------------------------ [2007-06-24 21:30:21] chris at w3style dot co dot uk Description: ------------ When comparing the values held in $_SERVER['SCRIPT_NAME'] in CGI and SAPI in PHP 5.2.3, there's an obvious bug in the CGI version. It works fine when the .php is the end of the URL, but in the case you use a URL like the following it breaks: http://site.com/script.php/some/extra/info Without the slash: [SCRIPT_NAME] => /~d11wtq/Router/demo.php With the slash: [SCRIPT_NAME] => tq/Sites/Router/demo.php This is probably because PHP is trying to truncate the wrong environment variable when producing the string. The path on disk is: /Users/d11wtq/Sites/Router/demo.php You'll notice that the length of the incorrect string is actually the same as the length of the correct string, which is why I make this assumption. I have found the following PHP code offers a suitable workaround until this bug is fixed: <?php if (isset($_SERVER["SCRIPT_NAME"])) { if (isset($_SERVER["ORIG_PATH_INFO"])) { $len = strlen($_SERVER["SCRIPT_NAME"]); if (($tmp = substr($_SERVER["ORIG_PATH_INFO"], 0, $len)) != $_SERVER["SCRIPT_NAME"]) { $_SERVER["SCRIPT_NAME"] = $tmp; } } } ?> Reproduce code: --------------- Not needed, the description explains it nicely :) Expected result: ---------------- $_SERVER["SCRIPT_NAME"] should contain the virtual path to the file in both cases. This should be: ~d11wtq/Router/demo.php Actual result: -------------- SCRIPT_NAME contains a bogus string when run under CGI, but only if there's a slash after the .php suffix. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41793&edit=1