diff options
| author | Scott MacVicar <scottmac@php.net> | 2008-07-22 16:18:37 +0000 |
|---|---|---|
| committer | Scott MacVicar <scottmac@php.net> | 2008-07-22 16:18:37 +0000 |
| commit | 9f26bea98fa2e7811728981f8597dd0562af8937 (patch) | |
| tree | 9772f30cfe6c4517339f827fc01ca0ce8d1890d1 /ext | |
| parent | ea85e2924f4fb04510b147f7e672b0bed014e989 (diff) | |
| download | php-git-9f26bea98fa2e7811728981f8597dd0562af8937.tar.gz | |
Add test for escapeshellcmd and restore previous behaviour with stripping % on Windows.
Diffstat (limited to 'ext')
| -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 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-- +<?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 |
