diff options
author | Scott MacVicar <scottmac@php.net> | 2008-07-22 16:21:16 +0000 |
---|---|---|
committer | Scott MacVicar <scottmac@php.net> | 2008-07-22 16:21:16 +0000 |
commit | d8d69652ddb4cd9c49071cb7b8d74b8bbb0e390d (patch) | |
tree | eb74407a7a4ed8366d20debf55741e7c9bc20bcc | |
parent | 2c54b3abb5fe5c4419064e0cdcf3eb6b702fa2fb (diff) | |
download | php-git-d8d69652ddb4cd9c49071cb7b8d74b8bbb0e390d.tar.gz |
MFH: Add test for escapeshellcmd and restore previous behaviour with stripping % on Windows.
-rw-r--r-- | ext/standard/exec.c | 7 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/escapeshellcmd-win32.phpt | 46 |
2 files changed, 51 insertions, 2 deletions
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-- +<?php +if( substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip...Valid for Windows only'); +} +?> +--FILE-- +<?php +echo "*** Testing escapeshellcmd() basic operations ***\n"; +$data = array( + '"abc', + "'abc", + '?<>', + '()[]{}$', + '%^', + '#&;`|*?', + '~<>\\' +); + +$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 |