Skip to content

Commit

Permalink
RequestFactory: script path detection is case-sensitive (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanTvrdik authored and dg committed Dec 27, 2014
1 parent 8846d00 commit 6e592e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/Http/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ public function createHttpRequest()
$url->setQuery(isset($tmp[1]) ? $tmp[1] : '');

// detect script path
$path = strtolower($path) . '/';
$path .= '/';
$script = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] . '/' : '/';
$script = strtolower($script);
$max = min(strlen($path), strlen($script));
for ($i = 0; $i < $max; $i++) {
if ($path[$i] !== $script[$i]) {
Expand Down
12 changes: 11 additions & 1 deletion tests/Http/RequestFactory.scriptPath.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test(function() use ($factory) {
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/projects/modules-usage/www/default/add-item',
'SCRIPT_NAME' => '/projects/Modules-Usage/www/index.php',
'SCRIPT_NAME' => '/projects/modules-usage/www/index.php',
);

Assert::same( '/projects/modules-usage/www/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
Expand Down Expand Up @@ -93,3 +93,13 @@ test(function() use ($factory) {

Assert::same( '/configuration/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});


test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/blog/WWW/',
'SCRIPT_NAME' => '/blog/www/index.php',
);

Assert::same( '/blog/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});

0 comments on commit 6e592e5

Please sign in to comment.