]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Parse "@key" with quotes as a setting key, not group include
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 8 Oct 2025 08:59:50 +0000 (11:59 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Fri, 10 Oct 2025 12:20:26 +0000 (12:20 +0000)
src/config/config-parser-private.h
src/config/config-parser.c
src/config/test-config-parser.c

index 69bb65a6a6f7b2f53fe74a3ea3df365c94e05c82..082c1c02e6c72f424567d3a0d7f14e067bf4f366 100644 (file)
@@ -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;
 };
 
index ba1950680165494c8772bc7bdef8212b8f3e4708..a45415b1e607a7f86f6a8618a82c9eae4d31104c 100644 (file)
@@ -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;
index acfd49c7e1c1bfaa81860daca3b1e4cc00b3ea5f..a0b39ea14d89b7658d24a6f3aca3d0c38deebca1 100644 (file)
@@ -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);