[php-src] Issue #7896: Env vars with non-ASCII values are mangled when read from $_SERVER on Windows
| From: | Seldaek | Date: | Thu, 06 Jan 2022 12:23:46 +0000 |
| Subject: | [php-src] Issue #7896: Env vars with non-ASCII values are mangled when read from $_SERVER on Windows | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238799@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7896
Author: Seldaek
### Description
The following code:
```php
<?php
var_dump(
$_SERVER['FOO'] ?? 'unset',
$_ENV['FOO'] ?? 'unset',
getenv('FOO')
);
```
When run with
variables_order = "EGPCS" and FOO=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:
```
string(7) "G?ter?"
string(7) "G?ter?"
string(11) "GüИter传"
```
But I expected this output instead:
```
string(11) "GüИter传"
string(11) "GüИter传"
string(11) "GüИter传"
```
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() returning string(7) "G?ter?" or string(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