From: Aki Tuomi Date: Fri, 1 Dec 2017 17:46:58 +0000 (+0200) Subject: lib: var-expand - handle \{ and \} correctly X-Git-Tag: 2.3.0.rc1~158 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5d1cfca5073424be87c85e40e893cea49257b75;p=thirdparty%2Fdovecot%2Fcore.git lib: var-expand - handle \{ and \} correctly Do not treat these as embedded braces --- diff --git a/src/lib/var-expand.c b/src/lib/var-expand.c index 57c7fecda6..5b07b37055 100644 --- a/src/lib/var-expand.c +++ b/src/lib/var-expand.c @@ -556,8 +556,17 @@ int var_expand_with_funcs(string_t *dest, const char *str, if (*str == '{' && (end = strchr(str, '}')) != NULL) { /* %{long_key} */ unsigned int ctr = 1; + bool escape = FALSE; end = str; while(*++end != '\0' && ctr > 0) { + if (!escape && *end == '\\') { + escape = TRUE; + continue; + } + if (escape) { + escape = FALSE; + continue; + } if (*end == '{') ctr++; if (*end == '}') ctr--; } @@ -659,6 +668,14 @@ var_get_key_range_full(const char *str, unsigned int *idx_r, /* long key */ *idx_r = ++i; for (; str[i] != '\0'; i++) { + if (!escape && str[i] == '\\') { + escape = TRUE; + continue; + } + if (escape) { + escape = FALSE; + continue; + } if (str[i] == '{') depth++; if (str[i] == '}') {