|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44945 escapeshellarg removes UTF-8 multi-byte characters
Submitted: 2008-05-08 11:08 UTC Modified: 2008-07-16 13:39 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: thomas dot jarosch at intra2net dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
 [2008-05-08 11:08 UTC] thomas dot jarosch at intra2net dot com
Hello together,

I'm seeing almost the same issue as #44564
after upgrading from PHP 5.2.5 to 5.2.6.

If I execute the provided test code via php CLI, everything works as 
expected. Running the same code via mod_php inside Apache skips the 
UTF-8 multi-byte characters.

I've looked at the ext/standard/exec.c code a bit and checked that 
my "config.log" in both PHP build directories contains
"#define HAVE_MBLEN 1" so the call to php_mblen() should work.

Any idea what that could be?

One thing I noticed is that php_mblen() is a wrapper macro for 
mblen() or mbrlen() which features a slight difference in the return 
code (see -2 rc for details).


Reproduce code:

Expected result:
string(2) "'?'"

Actual result:
string(2) "''"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-08 11:28 UTC]
Try with the code below (mandatory in the test):

if (false == setlocale(LC_CTYPE, "UTF8", "en_US.UTF-8")) {
	die("skip setlocale() failed\n");
 [2008-05-08 12:59 UTC] thomas dot jarosch at intra2net dot com
Thanks, that seems to work.

I've inspected the environment on the server and it contains a 
LANG="en_US.UTF-8" variable. Is there a way I can fix this/PHP 
autodetects it without touching every code using escapeshellarg()?
 [2008-07-13 17:01 UTC]
There's no automatic way. If you need to have it work with utf-8 of course you have to set the locales properly too. Or just not use UTF-8..
 [2008-07-16 13:39 UTC] thomas dot jarosch at intra2net dot com
Thanks for looking into this, Jani.

So, why does it work via CLI and not via apache if the same LANG 
environment variable is specified? I've even seen 
an "AddDefaultCharset UTF8" entry in the apache config.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Jun 08 05:03:37 2023 UTC