forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix phpGH-17645: FPM with httpd ProxyPass does not decode script path
This changes make FPM always decode SCRIPT_FILENAME when Apache ProxyPass or ProxyPassMatch is used. It also introduces a new INI option fastcgi.script_path_encoded that allows using the previous behavior of not decoding the path. The INI is introduced because there is a chance that some users could use encoded file paths in their file system as a workaround for the previous behavior. Close phpGH-17896
- Loading branch information
Showing
6 changed files
with
152 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--TEST-- | ||
FPM: FastCGI change for Apache ProxyPass SCRIPT_FILENAME decoding (GH-17645) | ||
--SKIPIF-- | ||
<?php include "skipif.inc"; ?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once "tester.inc"; | ||
|
||
$cfg = <<<EOT | ||
[global] | ||
error_log = {{FILE:LOG}} | ||
[unconfined] | ||
listen = {{ADDR}} | ||
pm = dynamic | ||
pm.max_children = 5 | ||
pm.start_servers = 1 | ||
pm.min_spare_servers = 1 | ||
pm.max_spare_servers = 3 | ||
php_admin_value[cgi.fix_pathinfo] = yes | ||
EOT; | ||
|
||
$code = <<<EOT | ||
<?php | ||
echo \$_SERVER["SCRIPT_NAME"] . "\n"; | ||
echo \$_SERVER["ORIG_SCRIPT_NAME"] . "\n"; | ||
echo \$_SERVER["SCRIPT_FILENAME"] . "\n"; | ||
echo \$_SERVER["PATH_INFO"] . "\n"; | ||
echo \$_SERVER["PHP_SELF"]; | ||
EOT; | ||
|
||
$tester = new FPM\Tester($cfg, $code); | ||
[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName('+'); | ||
$tester->start(); | ||
$tester->expectLogStartNotices(); | ||
$tester | ||
->request( | ||
uri: $scriptName . '/1%202', | ||
scriptFilename: "proxy:fcgi://" . $tester->getAddr() . str_replace('+', '%2B', $sourceFilePath) . '/1%202', | ||
scriptName: $scriptName . '/1 2' | ||
) | ||
->expectBody([$scriptName, $scriptName . '/1 2', $sourceFilePath, '/1 2', $scriptName . '/1 2']); | ||
$tester->terminate(); | ||
$tester->close(); | ||
|
||
?> | ||
Done | ||
--EXPECT-- | ||
Done | ||
--CLEAN-- | ||
<?php | ||
require_once "tester.inc"; | ||
FPM\Tester::clean(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--TEST-- | ||
FPM: FastCGI change for Apache ProxyPass SCRIPT_FILENAME decoding - fallback (GH-17645) | ||
--SKIPIF-- | ||
<?php include "skipif.inc"; ?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once "tester.inc"; | ||
|
||
$cfg = <<<EOT | ||
[global] | ||
error_log = {{FILE:LOG}} | ||
[unconfined] | ||
listen = {{ADDR}} | ||
pm = dynamic | ||
pm.max_children = 5 | ||
pm.start_servers = 1 | ||
pm.min_spare_servers = 1 | ||
pm.max_spare_servers = 3 | ||
php_admin_value[cgi.fix_pathinfo] = yes | ||
php_admin_value[fastcgi.script_path_encoded] = yes | ||
EOT; | ||
|
||
$code = <<<EOT | ||
<?php | ||
echo \$_SERVER["SCRIPT_NAME"] . "\n"; | ||
echo \$_SERVER["ORIG_SCRIPT_NAME"] . "\n"; | ||
echo \$_SERVER["SCRIPT_FILENAME"] . "\n"; | ||
echo \$_SERVER["PATH_INFO"] . "\n"; | ||
echo \$_SERVER["PHP_SELF"]; | ||
EOT; | ||
|
||
$tester = new FPM\Tester($cfg, $code); | ||
[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName('%2B'); | ||
$tester->start(); | ||
$tester->expectLogStartNotices(); | ||
$tester | ||
->request( | ||
uri: $scriptName . '/1%202', | ||
scriptFilename: "proxy:fcgi://" . $tester->getAddr() . $sourceFilePath . '/1%202', | ||
scriptName: $scriptName . '/1 2' | ||
) | ||
->expectBody([$scriptName, $scriptName . '/1 2', $sourceFilePath, '/1 2', $scriptName . '/1 2']); | ||
$tester->terminate(); | ||
$tester->close(); | ||
|
||
?> | ||
Done | ||
--EXPECT-- | ||
Done | ||
--CLEAN-- | ||
<?php | ||
require_once "tester.inc"; | ||
FPM\Tester::clean(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters