Skip to content

Commit 98cc19a

Browse files
committed
RequestFactory: script path detection is case-sensitive (BC break)
1 parent f781367 commit 98cc19a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/Http/RequestFactory.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,8 @@ public function createHttpRequest()
115115

116116
$path = $url->getPath();
117117
$max = min(strlen($path), strlen($script));
118-
for ($i = 0; $i < $max; $i++) {
119-
if ($path[$i] !== $script[$i] && strcasecmp($path[$i], $script[$i])) {
120-
break;
121-
}
118+
for ($i = 0; $i < $max && $path[$i] === $script[$i]; $i++) {
119+
// nothing
122120
}
123121
if ($i === $max && strlen($path) === strlen($script)) {
124122
$url->setScriptPath($path);

tests/Http/RequestFactory.scriptPath.phpt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test(function() use ($factory) {
2828
$_SERVER = array(
2929
'REQUEST_URI' => '/projects/modules-usage/www/default/add-item',
3030
'SCRIPT_FILENAME' => 'W:/projects/Modules-Usage/www/index.php',
31-
'SCRIPT_NAME' => '/projects/Modules-Usage/www/index.php',
31+
'SCRIPT_NAME' => '/projects/modules-usage/www/index.php',
3232
);
3333

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

9898
Assert::same( '/configuration/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
9999
});
100+
101+
102+
test(function() use ($factory) {
103+
$_SERVER = array(
104+
'REQUEST_URI' => '/blog/WWW/',
105+
'SCRIPT_NAME' => '/blog/www/index.php',
106+
);
107+
108+
Assert::same( '/blog/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
109+
});

0 commit comments

Comments
 (0)