mirror of
https://github.com/php/php-src.git
synced 2025-01-21 11:13:38 +08:00
Fixed bug #26285 (escapeshellarg() uses wrong quotes on windows).
This commit is contained in:
parent
b63803a06c
commit
2b7b909e16
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user