Skip to content

Case-sensitive file matching #91

Description

@Lokilein

Bug Report

In Laminas\Http\PhpEnvironment\Request::detectBaseUrl, the comparison of e.g. PHP_SELF, SCRIPT_NAME etc. is case-sensitive.
This leads to a bug with a bug in the IIS, which sometimes defines the paths in upper case after it was restarted. Another restart is neccesary to fix this.

However, I think it would be good if a strtolower would be used in the comparison of these functions to prevent effects of the case right away.

Q A
Version(s) 2.19.0

Summary

The detection of the base url is case-sensitive

Current behavior

Based on the different writing, the base URL cannot be detected correctly.

How to reproduce

Let's assume the $_SERVER-Array contains these variables:

$_SERVER = [...
	'PATH_TRANSLATED' => 'C:\inetpub\wwwroot\my_project\public\index.php',
	'ORIG_PATH_INFO' => '/my_project/public/index.php',
	'URL' => '/my_project/public/index.php',
	'SCRIPT_FILENAME' => 'C:\inetpub\wwwroot\my_project\public\index.php',
	'PHP_SELF' => 'my_project/public/index.php',
	...];

But in the error-case, it would be like this

$_SERVER = [...
	'PATH_TRANSLATED' => 'C:\inetpub\wwwroot\MY_PROJECT\PUBLIC\index.php',
	'ORIG_PATH_INFO' => '/MY_PROJECT/PUBLIC/index.php',
	'URL' => '/MY_PROJECT/PUBLIC/index.php',
	'SCRIPT_FILENAME' => 'C:\inetpub\wwwroot\MY_PROJECT\PUBLIC\index.php',
	'PHP_SELF' => 'MY_PROJECT/PUBLIC/index.php',
	...];

and the $requestUri would be /my_project/public/api/v1/endpoint, than it comes in the 2nd case to the conclusion, that there is // No match whatsoever, while in the first, correct case // Directory portion of base path matches. is the result.

Expected behavior

Thie case of the PHP_SELF should not matter in identifying the base path. URLs must not be case-sensitive, so there should be no reason to not compare this with lower case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions