From 3e0cbfb07797d11d005ddb8a40c1b5d018adad7c Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 18 May 2004 13:43:24 +0000 Subject: [PATCH] Fixed command line escaping routines for win32. --- ext/standard/exec.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ext/standard/exec.c b/ext/standard/exec.c index cc579e9be7..72fc668d2c 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -269,6 +269,7 @@ char *php_escape_shell_cmd(char *str) { switch (str[x]) { case '"': case '\'': +#ifndef PHP_WIN32 if (!p && (p = memchr(str + x + 1, str[x], l - x - 1))) { /* noop */ } else if (p && *p == str[x]) { @@ -278,6 +279,7 @@ char *php_escape_shell_cmd(char *str) { } cmd[y++] = str[x]; break; +#endif case '#': /* This is character-set independent */ case '&': case ';': @@ -299,6 +301,12 @@ char *php_escape_shell_cmd(char *str) { 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 cmd[y++] = '\\'; /* fall-through */ default: @@ -332,7 +340,9 @@ char *php_escape_shell_arg(char *str) { switch (str[x]) { #ifdef PHP_WIN32 case '"': - cmd[y++] = '\\'; + case '%': + cmd[y++] = ' '; + break; #else case '\'': cmd[y++] = '\''; -- 2.40.0