|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-05-30 09:35 UTC] RQuadling at GMail dot com
[2008-06-10 10:12 UTC] kalle@php.net
[2008-06-10 10:20 UTC] kalle@php.net
[2008-06-10 12:10 UTC] pajoye@php.net
[2008-07-22 16:22 UTC] scottmac@php.net
[2011-12-14 15:35 UTC] d dot kreuer at ibrams dot com
[2012-02-12 17:38 UTC] microsoftsux at gmx dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
Description: ------------ The windows version of escapeshellcmd replaces any of the special characters with a space, whereas, on other platforms it escapes them. There is a valid escape character for windows. It is the ^ character. Taking the current set of type-able characters from exec.c, the following is a proof of the ^ working ... 2007/11/12 13:22:42 V:\PHP\PHP5>echo foo ^' bar foo ' bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^" bar foo " bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^# bar foo # bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^$ bar foo $ bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^% bar foo % bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^& bar foo & bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^( bar foo ( bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^) bar foo ) bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^* bar foo * bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^; bar foo ; bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^? bar foo ? bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^[ bar foo [ bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^\ bar foo \ bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^] bar foo ] bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^^ bar foo ^ bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^` bar foo ` bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^{ bar foo { bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^| bar foo | bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^} bar foo } bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^~ bar foo ~ bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^< bar foo < bar 2007/11/12 13:22:43 V:\PHP\PHP5>echo foo ^> bar foo > bar I can't easily emulate 0xA0 and 0xFF in this test. I've included a patch also ... Index: exec.c =================================================================== RCS file: /repository/php-src/ext/standard/exec.c,v retrieving revision 1.125 diff -u -r1.125 exec.c --- exec.c 5 Nov 2007 14:06:19 -0000 1.125 +++ exec.c 12 Nov 2007 13:13:09 -0000 @@ -291,13 +291,12 @@ case '\\': case '\x0A': /* excluding these two */ case '\xFF': -#ifdef PHP_WIN32 - /* since Windows does not allow us to escape these chars, just remove them */ case '%': - cmd[y++] = ' '; - break; -#endif +#ifdef PHP_WIN32 + cmd[y++] = '^'; +#else cmd[y++] = '\\'; +#endif /* fall-through */ default: cmd[y++] = str[x]; http://rquadling.php1h.com/exec.c.patch.txt Reproduce code: --------------- php -r "exec(escapeshellcmd('echo foo | bar'), $a, $b); var_dump($a, $b);" Expected result: ---------------- array(1) { [0]=> string(10) "foo ^| bar" } int(0) Actual result: -------------- array(1) { [0]=> string(9) "foo bar" } int(0)