Skip to content

Commit

Permalink
Set $_SERVER['SCRIPT_NAME'] within proxy command (composer#11562)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Aug 2, 2023
1 parent f4738d9 commit 9c25633
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Composer/Installer/BinaryInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ public function url_stat(\$path, \$flags)
$globalsCode
$streamProxyCode
if (__FILE__ === realpath(\$_SERVER['SCRIPT_NAME'])) {
\$_SERVER['SCRIPT_NAME'] = realpath($binPathExported);
}
return include $binPathExported;
PROXY;
Expand Down
12 changes: 12 additions & 0 deletions tests/Composer/Test/Installer/BinaryInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ public static function executableBinaryProvider(): array
<?php declare(strict_types=1);
echo 'success '.$_SERVER['argv'][1];
EOL
],
'php file which validates $_SERVER["SCRIPT_NAME"]' => [<<<'EOL'
<?php
if (__FILE__ === realpath($_SERVER['SCRIPT_NAME'])) {
echo 'success '.$_SERVER['argv'][1];
} else {
fwrite(STDERR, "Test failure: __FILE__ does not match \$_SERVER['SCRIPT_NAME']\n");
fwrite(STDERR, "\t__FILE__:\t" . __FILE__ . "\n");
fwrite(STDERR, "\t\$_SERVER['SCRIPT_NAME']:\t" . $_SERVER['SCRIPT_NAME'] . "\n");
exit(1);
}
EOL
],
];
Expand Down

0 comments on commit 9c25633

Please sign in to comment.