I hit a weird problem with the default PHP 5.1.6 on CentoS 5.2.
It seems the default 5.1.6 PHP on CentOS has a bug in the functions escapeshellargs/escapeshellcmd: it "gulps" any special (non-ASCII) characters, so that they are missing from the output. I have been assured that this does not happen on other 5.1.6 or newer on other Linux distributions. I don't see this behavior with the exact same $LANG setting (en_US.UTF8) on CentOS 4. Moreover the behavior is different when running the script via console or webserver. If I run on console with my $LANG setting of en_US.UTF8 I get correct output if the input is UTF-8 (which is still incorrect, if the encoding doesn't match it should output garbage and not "nothing"). Via webserver I still get no output with the same characters and encoding of the page set to UTF-8. Could others check on what they have available (other PHP, other distributions) and tell the results?
a test page: <? $test = "äöüÄÖÜß"; print $test; print "<br>\n"; print escapeshellarg($test); print "<br>\n"; $test = "äöüÃÃÃÃ"; print $test; print "<br>\n"; print escapeshellarg($test); ?>
It will output German umlauts in ISO-8859-1 and UTF-8. Depending on your $LANG setting and the coding set to the webpage you may either get some correct characters or garbage between ''. The main point is that the respective output for lines 1 and 2 and for lines 3 and 4 should be *identical* with the exception of the outer single quotes. The function is supposed to escape single quotes and do nothing else with the input (e.g. output "as is"). If the output is only '', then there is a bug.
Kai
It's not specific to CentOS. I found this bug report http://bugs.php.net/bug.php?id=44945
It seems that PHP 5 runs with no locale at all and doesn't have access to $LANG either. That bug got closed, still I think it's a bug. At least it doesn't behave like documented.
Kai
Kai Schaetzl wrote:
Could others check on what they have available (other PHP, other distributions) and tell the results?
Linux Apache 2.6.9-55.0.2.EL #1 Tue Jun 26 14:08:18 EDT 2007 i686 CentOS release 4.5 (Final) PHP Version 5.2.5
Output:
äöüÄÖÜß 'äöüÄÖÜß' äöüÄÖÜß 'äöüÄÖÜß'
The main point is that the respective output for lines 1 and 2 and for lines 3 and 4 should be *identical* with the exception of the outer single quotes.
See above (hope it helps out).
Patrick
Patrick wrote on Sun, 12 Oct 2008 15:34:03 -0400:
See above (hope it helps out).
As you might have seen I actually found a workaround. Your findings on CentOS 4 suggest that it is a specific problem on the CentOS/RHEL 5 platform. The PHP 5 coming with CentOS 5 is set to a locale of C and doesn't match the locale of the system! I guess I file a bug now. Thanks!
Kai
Kai Schaetzl wrote:
As you might have seen I actually found a workaround. Your findings on CentOS 4 suggest that it is a specific problem on the CentOS/RHEL 5 platform. The PHP 5 coming with CentOS 5 is set to a locale of C and doesn't match the locale of the system! I guess I file a bug now. Thanks!
Kai
No problem !!
:-)
Patrick