diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2017-03-04 21:43:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-04 21:43:21 +0100 |
commit | 29f27cfb39a86094af746c1cd654d33436d29479 (patch) | |
tree | ceda3b35ac8830275c9d1f10d07e7dc8bfcb1ac2 /src/core | |
parent | dc99f8d7a5f90eebd4c52cef8d186bf20e2a9912 (diff) | |
parent | 027acffb4208d7e6ba8e229cbf6c3dae6f5dabaf (diff) | |
download | irssi-29f27cfb39a86094af746c1cd654d33436d29479.zip |
Merge pull request #658 from LemonBoy/dcc-autoaccept
Quote the filename when dcc requests are auto accepted.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/misc.c | 20 | ||||
-rw-r--r-- | src/core/misc.h | 4 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/core/misc.c b/src/core/misc.c index 1cfa15b6..03fcce59 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -724,18 +724,20 @@ int expand_escape(const char **data) } } -/* Escape all '"', "'" and '\' chars with '\' */ -char *escape_string(const char *str) +/* Escape all the characters in `what' with a backslash */ +char *escape_string(const char *str, const char *what) { - char *ret, *p; + const char *p; + char *ret; - p = ret = g_malloc(strlen(str)*2+1); - while (*str != '\0') { - if (*str == '"' || *str == '\'' || *str == '\\') - *p++ = '\\'; - *p++ = *str++; + ret = g_malloc(strlen(str) * 2 + 1); + for (p = str; *p != '\0'; p++, ret++) { + if (strchr(what, *p) != NULL) { + *ret++ = '\\'; + } + *ret = *p; } - *p = '\0'; + *ret = '\0'; return ret; } diff --git a/src/core/misc.h b/src/core/misc.h index 00637da0..9e620169 100644 --- a/src/core/misc.h +++ b/src/core/misc.h @@ -88,8 +88,8 @@ char *stristr_full(const char *data, const char *key); char *ascii_strup(char *str); char *ascii_strdown(char *str); -/* Escape all '"', "'" and '\' chars with '\' */ -char *escape_string(const char *str); +/* Escape all the characters in `what' with a backslash */ +char *escape_string(const char *str, const char *what); /* convert all low-ascii (<32) to ^<A..> combinations */ char *show_lowascii(const char *str); |