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 committed Dec 21, 2014
1 parent f781367 commit 98cc19a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/Http/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ public function createHttpRequest()

$path = $url->getPath();
$max = min(strlen($path), strlen($script));
for ($i = 0; $i < $max; $i++) {
if ($path[$i] !== $script[$i] && strcasecmp($path[$i], $script[$i])) {
break;
}
for ($i = 0; $i < $max && $path[$i] === $script[$i]; $i++) {
// nothing
}
if ($i === $max && strlen($path) === strlen($script)) {
$url->setScriptPath($path);
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 @@ -28,7 +28,7 @@ test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/projects/modules-usage/www/default/add-item',
'SCRIPT_FILENAME' => 'W:/projects/Modules-Usage/www/index.php',
'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 @@ -97,3 +97,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 98cc19a

Please sign in to comment.