Bug #75574 [Fbk->Csd]: putenv does not work properly if parameter contains non-ASCII unicode character

From: Date: Wed, 29 Nov 2017 05:44:19 +0000
Subject: Bug #75574 [Fbk->Csd]: putenv does not work properly if parameter contains non-ASCII unicode character
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212788@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75574&edit=1 ID: 75574 User updated by: ganlvtech at qq dot com Reported by: ganlvtech at qq dot com Summary: putenv does not work properly if parameter contains non-ASCII unicode character -Status: Feedback +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Windows 10 (1709) zh-CN PHP Version: 7.1.12 nts Win32 VC14 x64 Block user comment: N Private report: N New Comment: php-7.1-nts-windows-vc14-x64-r8b57a5b PHP 7.1.13-dev (cgi-fcgi) (built: Nov 28 2017 20:29:56) Test passed. And the issue can be closed. Thanks for your patience on this bug. And I'm sorry that bothering you for such a small bug. Previous Comments: ------------------------------------------------------------------------ [2017-11-28 19:50:04] ab@php.net @ganlvtech i've pushed a fix regarding FCGI, please check as soon as the snapshots for 8b57a5bca0c5a9ba064aa27e7614d1a11c0cac6d or later are produced. Not sure about the ticks execution yet, probably should dig more on that. Thanks. ------------------------------------------------------------------------ [2017-11-28 11:02:58] ganlvtech at qq dot com Using php.exe got expected result, but using php-cgi.exe putenv did not sets vars with Unicode. Test script: --------------- <?php var_dump(putenv('FOO=啊')); var_dump(echo %FOO%); // There will be a "\n" in the result. var_dump(getenv('FOO')); ?> Expected result: ---------------- bool(true) string(4) "啊 " string(3) "啊" Actual result: -------------- bool(true) string(3) "С " string(2) "С" The length of string is not equal to each other. putenv put vars using cp936 instead of Unicode. You can use another test script to view the difference. Test script: -------------- <?php var_dump(putenv('FOO=啊')); echo urlencode(echo %FOO%), PHP_EOL; echo urlencode(getenv('FOO')), PHP_EOL; ?> Expected result: ---------------- bool(true) %E5%95%8A%0A %E5%95%8A Actual result: -------------- bool(true) %B0%A1%0A %B0%A1 php snapshot: php-7.1-nts-windows-vc14-x64-r06202f0 ------------------------------------------------------------------------ [2017-11-28 06:05:54] ganlvtech at qq dot com Tested the newest snapshot (7.1.13-dev nts). Using test script from php-src/ext/standard/tests/general_functions/putenv_bug75574_utf8.phpt Run 'php test.php', test passed. Run 'php -S 127.0.0.1:8000', and visit http://127.0.0.1/test.php, test passed. But when I run 'php-cgi -b 127.0.0.1:9000', and use nginx fastcgi_pass to php-cgi, putenv is OK, but getenv will return cp936 2-byte char instead of utf8 3-byte char. (In fact, I start php-cgi with 'RunHiddenConsole php-cgi -b 127.0.0.1:9000') I would test some more to find if there's some error in my setting. ------------------------------------------------------------------------ [2017-11-27 17:53:15] ab@php.net Automatic comment on behalf of ab Revision: http://git.php.net/?p=php-src.git;a=commit;h=2b7d283cc5589077d7ecc23cc9b2827759cab5c2 Log: Fixed bug #75574 putenv does not work properly if parameter contains non-ASCII unicode character ------------------------------------------------------------------------ [2017-11-27 10:18:06] ab@php.net Thanks for more info. Yeah, i guess the issue is that we the A versions of the API are used. Getting a VM with Chinese simplified to check more. Thanks. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=75574 -- Edit this bug report at https://bugs.php.net/bug.php?id=75574&edit=1

« previous php.bugs (#212788) next »