From 12b32d871f5f8334b6834e439dcd6be62bca6a4f Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 19 Nov 2003 15:34:36 +0000 Subject: [PATCH] MFH: Fixed bug #26285 (escapeshellarg() uses wrong quotes on windows). --- NEWS | 1 + ext/standard/exec.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 9f99f4d3a2..b716b525b6 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ PHP 4 NEWS ?? ??? 2003, Version 4.3.5 - Fixed header handler in NSAPI SAPI module (header->replace was ignored, send_default_content_type now sends value from php.ini). (Uwe Schindler) +- Fixed bug #26285 (escapeshellarg() uses wrong quotes on windows). (Ilia) - Fixed bug #26267 (gmp_random() leaks memory and does not produce random numbers). (Jani) - Fixed bug #26253 (ext/tokenizer: build as shared extension fails). (Jani) diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 4fc2a07d39..729190f878 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -462,21 +462,33 @@ char *php_escape_shell_arg(char *str) { l = strlen(str); cmd = emalloc(4 * l + 3); /* worst case */ - +#ifdef PHP_WIN32 + cmd[y++] = '"'; +#else cmd[y++] = '\''; +#endif for (x = 0; x < l; x++) { switch (str[x]) { +#ifdef PHP_WIN32 + case '"': + cmd[y++] = '\\'; +#else case '\'': cmd[y++] = '\''; cmd[y++] = '\\'; cmd[y++] = '\''; +#endif /* fall-through */ default: cmd[y++] = str[x]; } } +#ifdef PHP_WIN32 + cmd[y++] = '"'; +#else cmd[y++] = '\''; +#endif cmd[y] = '\0'; return cmd; } -- 2.40.0