php.net |  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
Votes:1
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
Description:
------------
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).

Thanks,
Thomas


Reproduce code:
---------------
var_dump(escapeshellarg('?'));

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

Actual result:
--------------
string(2) "''"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-08 11:28 UTC] felipe@php.net
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] jani@php.net
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.

Thomas
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 05:01:30 2024 UTC