summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2014-06-05 00:45:53 +0200
committerDaniel Carl <danielcarl@gmx.de>2014-06-05 00:45:53 +0200
commitbe73f0a23d2a7346f9282351783eba4a6e05dc50 (patch)
tree20b6c51689f6590613eadd23d5ec16a1bd09b7a0 /src/util.c
parent62c038f0f79a2b25fdec503b688b27a63116c857 (diff)
Allow to escape all expandable chars.
The expandable chars are always allowed to be escaped by a \ if the expansion type is active.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c
index 078b718..0dcd0c3 100644
--- a/src/util.c
+++ b/src/util.c
@@ -352,7 +352,7 @@ char *util_expand(const char *src, int expflags)
int flags = expflags;
while (**input) {
- util_parse_expansion(input, dst, flags, "~$%\\");
+ util_parse_expansion(input, dst, flags, "\\");
if (VB_IS_SEPARATOR(**input)) {
/* after space the tilde expansion is allowed */
flags = expflags;
@@ -379,7 +379,7 @@ char *util_expand(const char *src, int expflags)
* @input: String pointer with the content to be parsed.
* @str: GString that will be filled with expanded content.
* @flags Flags that determine which expansion are processed.
- * @quoteable String of chars that are allowed to be escaped by \.
+ * @quoteable String of chars that are additionally escapable by \.
* Returns true if input started with expandable pattern.
*/
gboolean util_parse_expansion(const char **input, GString *str, int flags,
@@ -471,7 +471,11 @@ gboolean util_parse_expansion(const char **input, GString *str, int flags,
if (!*input) {
/* if input ends here - use only the quote char */
g_string_append_c(str, quote);
- } else if (strchr(quoteable, **input)) {
+ } else if (strchr(quoteable, **input)
+ || (flags & UTIL_EXP_TILDE && **input == '~')
+ || (flags & UTIL_EXP_DOLLAR && **input == '$')
+ || (flags & UTIL_EXP_SPECIAL && **input == '%')
+ ) {
/* escaped char becomes only char */
g_string_append_c(str, **input);
} else {