php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60180 $_SERVER["PHP_SELF"] incorrect
Submitted: 2011-10-31 17:25 UTC Modified: 2011-11-01 15:32 UTC
From: david dot gero at ec dot gc dot ca Assigned: laruence
Status: Closed Package: Built-in web server
PHP Version: 5.4SVN-2011-10-31 (snap) OS: Windows XP with SP3
Private report: No CVE-ID:
 [2011-10-31 17:25 UTC] david dot gero at ec dot gc dot ca
Description:
------------
When going to, for example, /admin/phpinfo.php/foo/bar?foo=bar, you should get the following (using Apache and PHP on Windows XP):

$_SERVER["REQUEST_URI"]  == "/admin/phpinfo.php/foo/bar?foo=bar"
$_SERVER["PHP_SELF"]     == "/admin/phpinfo.php/foo/bar"
$_SERVER["SCRIPT_NAME"]  == "/admin/phpinfo.php"
$_SERVER["PATH_INFO"]    == "/foo/bar"
$_SERVER["QUERY_STRING"] == "foo=bar"

In the snap for October 31, 2011, REQUEST_URI, PATH_INFO and QUERY_STRING are correct, but the following are wrong:

$_SERVER["PHP_SELF"] == "\admin\phpinfo.php" (slashes incorrectly replaced by backslashes, and PATH_INFO ending has been incorrectly removed)
$_SERVER["SCRIPT_NAME"] == (missing completely)

Test script:
---------------
phpinfo.php file contains:

<?php phpinfo(); ?>

Expected result:
----------------
Going to /admin/phpinfo.php/foo/bar?foo=bar should get:

$_SERVER["REQUEST_URI"]  == "/admin/phpinfo.php/foo/bar?foo=bar"
$_SERVER["PHP_SELF"]     == "/admin/phpinfo.php/foo/bar"
$_SERVER["SCRIPT_NAME"]  == "/admin/phpinfo.php"
$_SERVER["PATH_INFO"]    == "/foo/bar"
$_SERVER["QUERY_STRING"] == "foo=bar"


Actual result:
--------------
$_SERVER["REQUEST_URI"]  == "/admin/phpinfo.php/foo/bar?foo=bar" (correct)
$_SERVER["PHP_SELF"]     == "\admin\phpinfo.php" (incorrect)
$_SERVER["SCRIPT_NAME"]  == (not set)
$_SERVER["PATH_INFO"]    == "/foo/bar" (correct)
$_SERVER["QUERY_STRING"] == "foo=bar" (correct)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-31 17:40 UTC] david dot gero at ec dot gc dot ca
Should have said that the snap was tested with the built-in PHP web server, and I was comparing it against the standard Apache + PHP setup
 [2011-11-01 10:25 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2011-11-01 12:23 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=318639
Log: Fixed Bug #60180 ($_SERVER[&quot;PHP_SELF&quot;] incorrect)
 [2011-11-01 15:32 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2011-11-01 15:32 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2012-04-18 09:48 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c0402915e70e73d67c4618410b12fa23de2c74a0
Log: Fixed Bug #60180 ($_SERVER[&quot;PHP_SELF&quot;] incorrect)
 [2012-07-24 23:39 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c0402915e70e73d67c4618410b12fa23de2c74a0
Log: Fixed Bug #60180 ($_SERVER[&quot;PHP_SELF&quot;] incorrect)
 [2013-11-17 09:35 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c0402915e70e73d67c4618410b12fa23de2c74a0
Log: Fixed Bug #60180 ($_SERVER[&quot;PHP_SELF&quot;] incorrect)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 08:02:55 2014 UTC