-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Env vars with non-ASCII values are mangled when read from $_SERVER on Windows #7896
Comments
This is likely due to fixing https://bugs.php.net/75574, so should be fixed as of PHP 7.1.13 and 7.2.1, respectively. That fix only affected |
Thanks, do you see any way to mitigate/detect this in userland? I see that doing this when starting up to ensure
Once fixed in a release I'll at least be able to exclude this hackery from newer PHP versions. |
Nope, no better idea per se, but note that this wouldn't help with env var names containing non-ASCII characters (e.g. |
Ok yes using |
@cmb69 it's been brought to my attention that calling So here's a working workaround: https://github.com/composer/composer/blob/d9619985dbabb58255fb27cf78fe702345d31793/bin/composer#L68-L76 |
Argh! |
When bug 77574[1] has been fixed, the fix only catered to variables retrieved via `getenv()` with a `$varname` passed, but neither to `getenv()` without arguments nor to the general import of environment variables into `$_ENV` and `$_SERVER`. We catch up on this by using `GetEnvironmentStringsW()` in `_php_import_environment_variables()` and converting the encoding to whatever had been chosen by the user. [1] <https://bugs.php.net/bug.php?id=75574>
* PHP-8.0: Fix GH-7896: Environment vars may be mangled on Windows
* PHP-8.1: Fix GH-7896: Environment vars may be mangled on Windows
Thanks @cmb69 ! |
Description
The following code:
When run with
variables_order = "EGPCS"
andFOO=GüИter传
set in the environment variables in Windows (or using$env:FOO = 'GüИter传'
in PowerShell before executing the test file above).Resulted in this output:
But I expected this output instead:
Doing the same in WSL/Ubuntu seems to yield the correct result, so I assume it's Windows specific.
Regarding PHP version, it appears all versions <7.2 fail completely, with even
getenv()
returningstring(7) "G?ter?"
orstring(7) "Gⁿ?ter?"
for 5.x. From PHP 7.2 onwards I get the behavior described above.PHP Version
8.0.13
Operating System
Windows 10
The text was updated successfully, but these errors were encountered: