diff options
Diffstat (limited to 'Build/source/texk/xdvik/string-utils.c')
-rw-r--r-- | Build/source/texk/xdvik/string-utils.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/Build/source/texk/xdvik/string-utils.c b/Build/source/texk/xdvik/string-utils.c index a09a1b77762..062cd35248f 100644 --- a/Build/source/texk/xdvik/string-utils.c +++ b/Build/source/texk/xdvik/string-utils.c @@ -635,10 +635,10 @@ canonicalize_path(const char *path) return start; } -/* Escape all of the following characters in str: - ` \ ; ( ) & - making it safe to pass str to a shell. Return result in a newly - allocated string, which the caller is responsible to free() after use. +/* Escape shell metacharacters in str, hopefully making it safe to pass + str to system(), i.e., /bin/sh -c, without further quoting. Return + result in a newly allocated string, which the caller is responsible + to free() after use. */ char * shell_escape_string(const char *str) @@ -651,10 +651,20 @@ shell_escape_string(const char *str) while (*src_ptr != '\0') { if (*src_ptr == '\\' || *src_ptr == '`' - || *src_ptr == '(' - || *src_ptr == ')' + || *src_ptr == '\'' + || *src_ptr == '"' + || *src_ptr == '(' || *src_ptr == ')' + || *src_ptr == '{' || *src_ptr == '}' + || *src_ptr == '[' || *src_ptr == ']' + || *src_ptr == '<' || *src_ptr == '>' || *src_ptr == '&' - || *src_ptr == ';') { + || *src_ptr == '|' + || *src_ptr == '!' + || *src_ptr == '$' + || *src_ptr == '*' + || *src_ptr == '?' + || *src_ptr == ';' + || *src_ptr == ' ' || *src_ptr == '\t' || *src_ptr == '\n') { #if 0 /* only if not yet escaped? */ && (src_ptr == str || (src_ptr > str && *(src_ptr - 1) != '\\'))) { |