]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Support nested keys in var_get_key_range_full
authorAki Tuomi <aki.tuomi@dovecot.fi>
Fri, 1 Dec 2017 12:53:46 +0000 (14:53 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 5 Feb 2018 11:23:04 +0000 (13:23 +0200)
Fixes problems with %{if...}

failed: if: requires four or five parameters, got 1

src/lib/var-expand.c

index 2ed06bb3a9872a462d3e237d003cd0814244efce..c374014a0c8b6deefd90074381e4ae8624498344 100644 (file)
@@ -639,11 +639,17 @@ var_get_key_range_full(const char *str, unsigned int *idx_r,
                *size_r = str[i] == '\0' ? 0 : 1;
                return FALSE;
        } else {
+               unsigned int depth = 1;
+               bool escape = FALSE;
                /* long key */
                *idx_r = ++i;
                for (; str[i] != '\0'; i++) {
-                       if (str[i] == '}')
-                               break;
+                       if (str[i] == '{')
+                               depth++;
+                       if (str[i] == '}') {
+                               if (--depth==0)
+                                       break;
+                       }
                }
                *size_r = i - *idx_r;
                return TRUE;