Fixed bug #26285 (escapeshellarg() uses wrong quotes on windows).

This commit is contained in:
Ilia Alshanetsky 2003-11-19 15:34:30 +00:00
parent b63803a06c
commit 2b7b909e16

View File

@ -322,20 +322,33 @@ char *php_escape_shell_arg(char *str) {
cmd = safe_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;
}