Bug #77253 [NEW]: PHP_SELF value differs based on path to router script
| From: | andy at aiir dot com | Date: | Thu, 06 Dec 2018 16:59:55 +0000 |
| Subject: | Bug #77253 [NEW]: PHP_SELF value differs based on path to router script | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-218295@lists.php.net to get a copy of this message | ||
From: andy at aiir dot com
Operating system: *nix
PHP version: 7.2.13
Package: Built-in web server
Bug Type: Bug
Bug description:PHP_SELF value differs based on path to router script
Description:
------------
When running the PHP internal web server, the location of the router
script affects the output of the PHP_SELF value in an unusual way.
If I run PHP from the folder with the script in:
$ php -S 0:8080 index.php
And then call http://localhost:8080/, the value for PHP_SELF
is
/index.php. If I run the script from a parent directory (or any other
location that differs from the script), e.g.:
$ php -S 0:8080 src/index.php
The value for PHP_SELF when request http://localhost:8080/foo/bar will
be /foo/bar.
I'm not certain if this behaviour is intentional or not, but if it is,
why is it this way? We noticed this issue because it breaks a lot of
popular routing libraries as they strip the content of PHP_SELF from the
variable they discern the path from, so it fails to route requests
correctly.
Test script:
---------------
<?php echo $_SERVER['PHP_SELF'];
Expected result:
----------------
Expect the PHP_SELF value to always provide a path to the script, not
change between this and the web requested path.
--
Edit bug report at https://bugs.php.net/bug.php?id=77253&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77253&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77253&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77253&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77253&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77253&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77253&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77253&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77253&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77253&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77253&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77253&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77253&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77253&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77253&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77253&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77253&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77253&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77253&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77253&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77253&r=mysqlcfg