From: Scott MacVicar Date: Tue, 22 Jul 2008 16:21:16 +0000 (+0000) Subject: MFH: Add test for escapeshellcmd and restore previous behaviour with stripping %... X-Git-Tag: php-5.3.0alpha1~211 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d8d69652ddb4cd9c49071cb7b8d74b8bbb0e390d;p=php MFH: Add test for escapeshellcmd and restore previous behaviour with stripping % on Windows. --- diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 0f00df2665..79157b8186 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -299,6 +299,11 @@ PHPAPI char *php_escape_shell_cmd(char *str) } cmd[y++] = str[x]; break; +#else + /* This is Windows specific for enviromental variables */ + case '%': + cmd[y++] = ''; + break; #endif case '#': /* This is character-set independent */ case '&': @@ -322,8 +327,6 @@ PHPAPI char *php_escape_shell_cmd(char *str) case '\x0A': /* excluding these two */ case '\xFF': #ifdef PHP_WIN32 - /* This is Windows specific for enviromental variables */ - case '%': cmd[y++] = '^'; #else cmd[y++] = '\\'; diff --git a/ext/standard/tests/general_functions/escapeshellcmd-win32.phpt b/ext/standard/tests/general_functions/escapeshellcmd-win32.phpt new file mode 100644 index 0000000000..3da43e15f7 --- /dev/null +++ b/ext/standard/tests/general_functions/escapeshellcmd-win32.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test escapeshellcmd() functionality on Windows +--SKIPIF-- + +--FILE-- +', + '()[]{}$', + '%^', + '#&;`|*?', + '~<>\\' +); + +$count = 1; +foreach ($data AS $value) { + echo "-- Test " . $count++ . " --\n"; + var_dump(escapeshellcmd($value)); +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing escapeshellcmd() basic operations *** +-- Test 1 -- +string(5) "^"abc" +-- Test 2 -- +string(5) "^'abc" +-- Test 3 -- +string(6) "^?^<^>" +-- Test 4 -- +string(14) "^(^)^[^]^{^}^$" +-- Test 5 -- +string(2) "^^" +-- Test 6 -- +string(14) "^#^&^;^`^|^*^?" +-- Test 7 -- +string(8) "^~^<^>^\" +Done