Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case-sensitive file matching #91

Open
Lokilein opened this issue Dec 3, 2024 · 0 comments
Open

Case-sensitive file matching #91

Lokilein opened this issue Dec 3, 2024 · 0 comments
Labels
Bug Something isn't working

Comments

@Lokilein
Copy link

Lokilein commented Dec 3, 2024

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.

@Lokilein Lokilein added the Bug Something isn't working label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant