|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-04-22 19:16 UTC] twm at twmacinta dot com
Description:
------------
When I run a PHP script which uses passthru() to execute a command with characters that need escaping, the escaping is incorrect when the script is run from the command line, but it is fine when the script is run from within Apache. This was causing the script "ext/standard/tests/file/bug22414.phpt" to fail when I attempted to run "make test" after building PHP 5.2.5 on RHEL3. I have created a simplified script for this report to demonstrate the problem, though I will note that I can also reproduce it reliably with "bug22414.phpt".
I should mention that I also tried my test script from the command line in Mac OS X 10.5 running PHP 5.2.5 and Ubuntu 7.10 running PHP 5.2.3 and it worked correctly in both cases. So, my suspicion is that there is an older library on RHEL3 which is causing the parsing the be incorrect. It passes all the requirements checks made by './configure', though.
I ran the test code below using the '-n' option to PHP so as to eliminate my "php.ini" as the problem.
Reproduce code:
---------------
header("Content-Type: text/plain");
$textEscaped = escapeshellarg("Tim's Test");
print("Before: {$textEscaped}\n");
print("After: ");
passthru("/bin/echo {$textEscaped}");
Expected result:
----------------
Before: 'Tim'\''s Test'
After: Tim's Test
Actual result:
--------------
Before: 'Tim'\''s Test'
After: Tim\s Test'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 26 23:00:01 2025 UTC |
]$ php t.php Before: 'Tim'\''s Test' After: Tim's Test So it works fine using latest CVS (for me). You're using /bin/echo there, what if you simply do this: <?php header("Content-Type: text/plain"); $textEscaped = escapeshellarg("Tim's Test"); print("Before: {$textEscaped}\n"); print("After: "); passthru($textEscaped); ?> That would eliminate one "moving part" here.. Just check the resulting error message what it has. :)I was actually using the "-n" flag from the start, so that moving part was already eliminated. Here are my "./configure" and "make install" commands: ---- CONF_OLD_PREFIX=/usr CONF_PREFIX=/var/tmp2/php5_take2/targ CONF_SYSCONFDIR=${CONF_PREFIX}/etc CONF_BINDIR=${CONF_PREFIX}/bin ./configure \ --prefix=${CONF_PREFIX} \ --with-config-file-path=${CONF_SYSCONFDIR} \ --enable-force-cgi-redirect \ --enable-fastcgi \ --disable-debug \ --enable-pic \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --with-curl \ --with-dom=${CONF_PREFIX} \ --with-exec-dir=${CONF_BINDIR} \ --with-freetype-dir=${CONF_PREFIX} \ --with-png-dir=${CONF_PREFIX} \ --with-gd \ --enable-gd-native-ttf \ --with-ttf \ --with-gdbm \ --with-gettext \ --with-db4 \ --with-ncurses \ --with-gmp \ --with-iconv \ --with-jpeg-dir=${CONF_PREFIX} \ --with-mm \ --with-openssl \ --with-png \ --with-pspell \ --with-regex=system \ --with-xml \ --with-domxml \ --with-expat-dir=${CONF_PREFIX} \ --with-zlib \ --with-layout=GNU \ --enable-mcal \ --enable-bcmath \ --enable-debugger \ --enable-exif \ --enable-ftp \ --enable-magic-quotes \ --enable-safe-mode \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-discard-path \ --enable-track-vars \ --enable-trans-sid \ --enable-yp \ --enable-wddx \ --without-oci8 \ --with-imap=shared \ --with-mcrypt \ --with-imap-ssl \ --with-kerberos=/usr/kerberos \ --with-ldap=shared \ --with-mysql=shared,${CONF_PREFIX} \ --with-pgsql=shared \ --with-snmp=shared,${CONF_PREFIX} \ --with-snmp=shared \ --enable-net-snmp-hack \ --with-unixODBC=shared,${CONF_OLD_PREFIX} \ --enable-memory-limit \ --enable-bcmath \ --enable-shmop \ --enable-versioning \ --enable-calendar \ --enable-dbx \ --enable-dio \ --enable-mbstring \ --enable-mbstr-enc-trans make install INSTALL_ROOT=/var/tmp2/php5_take2/targ