Bug #66711 [Opn]: PHP_SELF has trailing slash for index.php

From: Date: Fri, 14 Feb 2014 19:34:55 +0000
Subject: Bug #66711 [Opn]: PHP_SELF has trailing slash for index.php
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184298@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66711&edit=1

 ID:                 66711
 User updated by:    cmbecker69 at gmx dot de
 Reported by:        cmbecker69 at gmx dot de
 Summary:            PHP_SELF has trailing slash for index.php
 Status:             Open
 Type:               Bug
 Package:            Built-in web server
 Operating System:   Windows 7
 PHP Version:        5.5.9
 Block user comment: N
 Private report:     N

 New Comment:

I have to correct myself: it always happens when a trailing slash
is appended to the URL.

From what I can tell, this issue is related to the stat() call in
php_cli_server_request_translate_vpath().  While *nix (tested on
Cygwin) returns 0 for an existing directory with a trailing slash,
Windows returns -1 (on Windows the directory separator is properly
changed to backslash).  This bypasses the break on line 1509, and
causes prev_path to be changed to "\", what is later assigned to
request->path_info.

In sapi_cli_server_register_variables() PHP_SELF is finally set by
using the wrong path_info[2].

My knowledge of C is limited, so I'm not able to appropriately fix
the bug; however, I've sent a respective phpt to the QA list[3].

[1] <http://lxr.php.net/xref/PHP_5_5/sapi/cli/php_cli_server.c#1486>
[2] <http://lxr.php.net/xref/PHP_5_5/sapi/cli/php_cli_server.c#790>
[3] <http://news.php.net/php.qa/67222>


Previous Comments:
------------------------------------------------------------------------
[2014-02-13 22:32:59] cmbecker69 at gmx dot de

Description:
------------
When requesting the document root, the built-in webserver appends
a superfluous and AFAICT erroneous slash to $_SERVER['PHP_SELF'].

This does neither happen when the file index.php is requested
directly, nor when a subdirectory is requested.

Test script:
---------------
<?php

var_dump($_SERVER['PHP_SELF']);

Expected result:
----------------
string(11) "/index.php/"

Actual result:
--------------
string(10) "/index.php"


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=66711&edit=1


Thread (8 messages)

« previous php.bugs (#184298) next »