1
0
Fork 0

improved quoting of args

This commit is contained in:
bagyenda 2006-03-03 05:36:07 +00:00
parent 7644c1d064
commit e1a4f3d031
1 changed files with 4 additions and 5 deletions

View File

@ -1036,24 +1036,23 @@ int is_allowed_host(Octstr *host, Octstr *host_list)
return ret;
}
#define SHELLCHARS "'|\"()[]{}$&!?*><%`\n \t"
#define SHELLCHARS "'|\"()[]{}$&!?*><%`\n \t\\"
void escape_shell_chars(Octstr *str)
{
Octstr *tmp;
int i, n, prev;
int i, n;
octstr_strip_blanks(str);
tmp = octstr_duplicate(str);
octstr_delete(str, 0, octstr_len(str));
for (i = 0, prev=0, n = octstr_len(tmp); i < n; i++) {
for (i = 0, n = octstr_len(tmp); i < n; i++) {
int ch = octstr_get_char(tmp,i);
if (strchr(SHELLCHARS, ch) != NULL && prev != '\\')
if (strchr(SHELLCHARS, ch) != NULL)
octstr_append_char(str, '\\');
octstr_append_char(str, ch);
prev = ch;
}
octstr_destroy(tmp);
}