mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Fixed Bug #60180 ($_SERVER["PHP_SELF"] incorrect)
This commit is contained in:
parent
58a134fb48
commit
ac789e0bb6
1
NEWS
1
NEWS
@ -9,6 +9,7 @@ PHP NEWS
|
||||
(Laruence)
|
||||
. Fixed bug #60115 (memory definitely lost in cli server). (Laruence)
|
||||
. Fixed bug #60146 (Last 2 lines of page not being output). (Laruence)
|
||||
. Fixed bug #60180 ($_SERVER["PHP_SELF"] incorrect). (Laruence)
|
||||
|
||||
- Core:
|
||||
. Fixed bug #60120 (proc_open's streams may hang with stdin/out/err when
|
||||
|
@ -579,13 +579,21 @@ static void sapi_cli_server_register_variables(zval *track_vars_array TSRMLS_DC)
|
||||
}
|
||||
sapi_cli_server_register_variable(track_vars_array, "REQUEST_URI", client->request.request_uri TSRMLS_CC);
|
||||
sapi_cli_server_register_variable(track_vars_array, "REQUEST_METHOD", SG(request_info).request_method TSRMLS_CC);
|
||||
sapi_cli_server_register_variable(track_vars_array, "PHP_SELF", client->request.vpath TSRMLS_CC);
|
||||
sapi_cli_server_register_variable(track_vars_array, "SCRIPT_NAME", client->request.vpath TSRMLS_CC);
|
||||
if (SG(request_info).path_translated) {
|
||||
sapi_cli_server_register_variable(track_vars_array, "SCRIPT_FILENAME", SG(request_info).path_translated TSRMLS_CC);
|
||||
}
|
||||
if (client->request.path_info) {
|
||||
sapi_cli_server_register_variable(track_vars_array, "PATH_INFO", client->request.path_info TSRMLS_CC);
|
||||
}
|
||||
if (client->request.path_info_len) {
|
||||
char *tmp;
|
||||
spprintf(&tmp, 0, "%s%s", client->request.vpath, client->request.path_info);
|
||||
sapi_cli_server_register_variable(track_vars_array, "PHP_SELF", tmp TSRMLS_CC);
|
||||
efree(tmp);
|
||||
} else {
|
||||
sapi_cli_server_register_variable(track_vars_array, "PHP_SELF", client->request.vpath TSRMLS_CC);
|
||||
}
|
||||
if (client->request.query_string) {
|
||||
sapi_cli_server_register_variable(track_vars_array, "QUERY_STRING", client->request.query_string TSRMLS_CC);
|
||||
}
|
||||
@ -1330,6 +1338,16 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque
|
||||
request->path_translated = buf;
|
||||
request->path_translated_len = q - buf;
|
||||
}
|
||||
#ifdef PHP_WIN32
|
||||
{
|
||||
uint i = 0;
|
||||
for (;i<request->vpath_len;i++) {
|
||||
if (request->vpath[i] == '\\') {
|
||||
request->vpath[i] = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
request->sb = sb;
|
||||
} /* }}} */
|
||||
|
||||
|
75
sapi/cli/tests/php_cli_server_010.phpt
Normal file
75
sapi/cli/tests/php_cli_server_010.phpt
Normal file
@ -0,0 +1,75 @@
|
||||
--TEST--
|
||||
Bug #60180 ($_SERVER["PHP_SELF"] incorrect)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include "skipif.inc";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "php_cli_server.inc";
|
||||
php_cli_server_start('var_dump($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"], $_SERVER["PATH_INFO"], $_SERVER["QUERY_STRING"]);', TRUE);
|
||||
|
||||
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
|
||||
$port = intval($port)?:80;
|
||||
|
||||
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
||||
if (!$fp) {
|
||||
die("connect failed");
|
||||
}
|
||||
|
||||
if(fwrite($fp, <<<HEADER
|
||||
GET /foo/bar?foo=bar HTTP/1.1
|
||||
Host: {$host}
|
||||
|
||||
|
||||
HEADER
|
||||
)) {
|
||||
while (!feof($fp)) {
|
||||
echo fgets($fp);
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
|
||||
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
||||
if (!$fp) {
|
||||
die("connect failed");
|
||||
}
|
||||
|
||||
|
||||
if(fwrite($fp, <<<HEADER
|
||||
GET /index.php/foo/bar/?foo=bar HTTP/1.0
|
||||
Host: {$host}
|
||||
|
||||
|
||||
HEADER
|
||||
)) {
|
||||
while (!feof($fp)) {
|
||||
echo fgets($fp);
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
HTTP/1.1 200 OK
|
||||
Host: %s
|
||||
Connection: closed
|
||||
X-Powered-By: PHP/%s
|
||||
Content-type: text/html
|
||||
|
||||
string(18) "/index.php/foo/bar"
|
||||
string(10) "/index.php"
|
||||
string(8) "/foo/bar"
|
||||
string(7) "foo=bar"
|
||||
HTTP/1.0 200 OK
|
||||
Host: %s
|
||||
Connection: closed
|
||||
X-Powered-By: PHP/%s
|
||||
Content-type: text/html
|
||||
|
||||
string(19) "/index.php/foo/bar/"
|
||||
string(10) "/index.php"
|
||||
string(9) "/foo/bar/"
|
||||
string(7) "foo=bar"
|
Loading…
Reference in New Issue
Block a user