From 7dec4387d73370389f322e422cb590262b4c9dea Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 3 Feb 2016 11:29:34 +0000 Subject: [PATCH] Fix parsing nested braces inside logger vars --- src/libserver/cfg_utils.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index b6b44036e..7551e64ef 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -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++; } -- 2.39.5