From 9f26bea98fa2e7811728981f8597dd0562af8937 Mon Sep 17 00:00:00 2001 From: Scott MacVicar Date: Tue, 22 Jul 2008 16:18:37 +0000 Subject: [PATCH] Add test for escapeshellcmd and restore previous behaviour with stripping % on Windows. --- ext/standard/exec.c | 7 ++- .../escapeshellcmd-win32.phpt | 46 +++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 ext/standard/tests/general_functions/escapeshellcmd-win32.phpt diff --git a/ext/standard/exec.c b/ext/standard/exec.c index f085fc68aa..6cf33a7493 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -284,6 +284,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 '&': @@ -307,8 +312,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 -- 2.40.0