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

From: Date: Tue, 17 Aug 2021 11:28:15 +0000
Subject: Bug #66711 [Opn->Csd]: PHP_SELF has trailing slash for index.php
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235895@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 Updated by: cmb@php.net Reported by: cmbecker69 at gmx dot de Summary: PHP_SELF has trailing slash for index.php -Status: Open +Status: Closed Type: Bug Package: Built-in web server Operating System: Windows 7 PHP Version: 5.5.9 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Oh, this is apparently fixed as of PHP 7.0.0. Previous Comments: ------------------------------------------------------------------------ [2014-04-05 11:34:58] cmbecker69 at gmx dot de > i think this is a duplicate of the slash-bug, reported at > https://bugs.php.net/bug.php?id=66191 No, the issues are not related. I have filed a feature request regarding the "trailing slash" redirect (#67027), because I assume it is futile to add comments to an already closed bug report. ------------------------------------------------------------------------ [2014-04-05 11:07:50] cmbecker69 at gmx dot de I have just noticed, that the expected and actual results given above are permuted. That should have been: Expected result: ---------------- string(10) "/index.php" Actual result: -------------- string(11) "/index.php/" ------------------------------------------------------------------------ [2014-04-05 01:48:46] jakoch at web dot de i think this is a duplicate of the slash-bug, reported at https://bugs.php.net/bug.php?id=66191 sadly the issue was closed without even checking it. ------------------------------------------------------------------------ [2014-02-14 19:34:55] cmbecker69 at gmx dot de 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> ------------------------------------------------------------------------ [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

« previous php.bugs (#235895) next »