From: Timo Sirainen Date: Wed, 8 Oct 2025 08:59:50 +0000 (+0300) Subject: config: Parse "@key" with quotes as a setting key, not group include X-Git-Tag: 2.4.2~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a57bbaddb03e04621a67a5cd0bf7d83816e9841;p=thirdparty%2Fdovecot%2Fcore.git config: Parse "@key" with quotes as a setting key, not group include --- diff --git a/src/config/config-parser-private.h b/src/config/config-parser-private.h index 69bb65a6a6..082c1c02e6 100644 --- a/src/config/config-parser-private.h +++ b/src/config/config-parser-private.h @@ -34,7 +34,8 @@ struct config_line { enum config_line_type type; const char *key; const char *value; - /* value is inside "quotes" */ + /* key/value is inside "quotes" */ + bool key_quoted; bool value_quoted; }; diff --git a/src/config/config-parser.c b/src/config/config-parser.c index ba19506801..a45415b1e6 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -2185,6 +2185,7 @@ config_parse_line(struct config_parser_context *ctx, c) } */ key = line; if (*key == '"') { + config_line_r->key_quoted = TRUE; key++; line++; while (*line != '\0') { if (*line == '\\' && line[1] != '\0') @@ -3130,7 +3131,8 @@ void config_parser_apply_line(struct config_parser_context *ctx, if (config_write_value(ctx, line) < 0) { if (config_apply_error(ctx, line->key) < 0) break; - } else if (line->key[0] == SETTINGS_INCLUDE_GROUP_PREFIX) { + } else if (line->key[0] == SETTINGS_INCLUDE_GROUP_PREFIX && + !line->key_quoted) { if (config_filter_has_include_group(&ctx->cur_section->filter_parser->filter)) { ctx->error = "Recursive include groups not allowed"; break; diff --git a/src/config/test-config-parser.c b/src/config/test-config-parser.c index acfd49c7e1..a0b39ea14d 100644 --- a/src/config/test-config-parser.c +++ b/src/config/test-config-parser.c @@ -28,6 +28,7 @@ struct test_settings { const char *env_key4; const char *env_key5; const char *protocols; + const char *at_group_name; }; static const struct setting_define test_settings_defs[] = { @@ -43,6 +44,7 @@ static const struct setting_define test_settings_defs[] = { SETTING_DEFINE_STRUCT_STR("env_key4", env_key4, struct test_settings), SETTING_DEFINE_STRUCT_STR("env_key5", env_key5, struct test_settings), SETTING_DEFINE_STRUCT_STR("protocols", protocols, struct test_settings), + SETTING_DEFINE_STRUCT_STR("@group_name", at_group_name, struct test_settings), SETTING_DEFINE_LIST_END }; @@ -59,6 +61,7 @@ static const struct test_settings test_settings_defaults = { .env_key4 = "", .env_key5 = "", .protocols = "pop3", + .at_group_name = "", }; const struct setting_parser_info test_settings_info = { @@ -111,6 +114,7 @@ static void test_config_parser(void) "env_key4 = $ENV:foo $ENV:bar $SET:key\n" "env_key5 = $ENV:foo $ENV:foo\n" "protocols = $SET:protocols imap\n" +"\"@group_name\" = value\n" ); putenv("foo=test1"); @@ -145,6 +149,7 @@ static void test_config_parser(void) test_assert_strcmp(set->env_key4, "test1 test2 value"); test_assert_strcmp(set->env_key5, "test1 test1"); test_assert_strcmp(set->protocols, "pop3 imap"); + test_assert_strcmp(set->at_group_name, "value"); settings_parser_unref(&set_parser); config_parsed_free(&config); @@ -172,6 +177,7 @@ static void test_config_parser(void) test_assert_strcmp(set->env_key4, "$ENV:foo $ENV:bar $SET:key"); test_assert_strcmp(set->env_key5, "$ENV:foo $ENV:foo"); test_assert_strcmp(set->protocols, "pop3 imap"); + test_assert_strcmp(set->at_group_name, "value"); settings_parser_unref(&set_parser); config_parsed_free(&config);