]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Do not consume {} inside %{}
authorAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 27 Oct 2016 13:19:52 +0000 (16:19 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 9 Nov 2016 12:31:24 +0000 (14:31 +0200)
src/lib/var-expand.c

index deb92600632ad23b0d50e295f68659c880e63290..f2da1f4e52577e33da9acc86516b9063a6e33ed6 100644 (file)
@@ -324,6 +324,17 @@ void var_expand_with_funcs(string_t *dest, const char *str,
                        var = NULL;
                        if (*str == '{' && (end = strchr(str, '}')) != NULL) {
                                /* %{long_key} */
+                               unsigned int ctr = 1;
+                               end = str;
+                               while(*++end != '\0' && ctr > 0) {
+                                       if (*end == '{') ctr++;
+                                       if (*end == '}') ctr--;
+                               }
+                               if (ctr == 0)
+                                       /* it needs to come back a bit */
+                                       end--;
+                               /* if there is no } it will consume rest of the
+                                  string */
                                len = end - (str + 1);
                                var = var_expand_long(table, func_table,
                                                      str+1, len, context);