]> source.dussan.org Git - rspamd.git/commitdiff
Fix parsing nested braces inside logger vars
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 3 Feb 2016 11:29:34 +0000 (11:29 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 3 Feb 2016 11:29:34 +0000 (11:29 +0000)
src/libserver/cfg_utils.c

index b6b44036ecdd051c26c8781670f90c4d6e321c47..7551e64ef49db2ae31457db5c2808c8cdeff08da 100644 (file)
@@ -421,6 +421,7 @@ rspamd_config_parse_log_format (struct rspamd_config *cfg)
                parse_var_name,
                parse_var_content,
        } state = parse_str;
+       gint braces = 0;
 
        g_assert (cfg != NULL);
        c = cfg->log_format_str;
@@ -478,6 +479,7 @@ rspamd_config_parse_log_format (struct rspamd_config *cfg)
                                p ++;
                                c = p;
                                state = parse_var_content;
+                               braces = 1;
                        }
                        else if (*p != '_' && *p != '-' && !g_ascii_isalnum (*p)) {
                                /* Variable with no content */
@@ -496,7 +498,7 @@ rspamd_config_parse_log_format (struct rspamd_config *cfg)
                        }
                        break;
                case parse_var_content:
-                       if (*p == '}') {
+                       if (*p == '}' && --braces == 0) {
                                var_content.begin = c;
                                var_content.len = p - c;
                                p ++;
@@ -508,6 +510,10 @@ rspamd_config_parse_log_format (struct rspamd_config *cfg)
 
                                state = parse_str;
                        }
+                       else if (*p == '{') {
+                               braces ++;
+                               p ++;
+                       }
                        else {
                                p++;
                        }