From: Timo Sirainen Date: Tue, 6 Dec 2011 22:30:26 +0000 (+0200) Subject: config: Allow section names to contain spaces. X-Git-Tag: 2.1.rc2~97 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d477b279ecb46c3e38bb505eefc6fbd20056905e;p=thirdparty%2Fdovecot%2Fcore.git config: Allow section names to contain spaces. --- diff --git a/src/config/config-parser.c b/src/config/config-parser.c index 7f85a02cf9..3cfce8a6f0 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -642,14 +642,25 @@ config_parse_line(struct config_parser_context *ctx, *value_r = ""; else { /* get section name */ - *value_r = line; - while (!IS_WHITE(*line) && *line != '\0') - line++; - - if (*line != '\0') { - *line++ = '\0'; - while (IS_WHITE(*line)) + if (*line != '"') { + *value_r = line; + while (!IS_WHITE(*line) && *line != '\0') + line++; + if (*line != '\0') { + *line++ = '\0'; + while (IS_WHITE(*line)) + line++; + } + } else { + char *value = ++line; + while (*line != '"' && *line != '\0') line++; + if (*line == '"') { + *line++ = '\0'; + while (IS_WHITE(*line)) + line++; + *value_r = str_unescape(value); + } } if (*line != '{') { *value_r = "Expecting '='"; diff --git a/src/config/doveconf.c b/src/config/doveconf.c index b3e8b4af32..7ff9eb45b6 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -270,8 +270,12 @@ config_dump_human_output(struct config_dump_human_context *ctx, str_append_n(ctx->list_prefix, key2, p - key2); else str_append(ctx->list_prefix, key2); - if (unique_key && *value != '\0') - str_printfa(ctx->list_prefix, " %s", value); + if (unique_key && *value != '\0') { + if (strchr(value, ' ') == NULL) + str_printfa(ctx->list_prefix, " %s", value); + else + str_printfa(ctx->list_prefix, " \"%s\"", str_escape(value)); + } str_append(ctx->list_prefix, " {\n"); indent++; diff --git a/src/lib-settings/settings-parser.c b/src/lib-settings/settings-parser.c index ee1206f06f..0ab60b1a5f 100644 --- a/src/lib-settings/settings-parser.c +++ b/src/lib-settings/settings-parser.c @@ -1989,7 +1989,7 @@ int settings_parser_apply_changes(struct setting_parser_context *dest, const char *settings_section_escape(const char *name) { #define CHAR_NEED_ESCAPE(c) \ - ((c) == '=' || (c) == SETTINGS_SEPARATOR || (c) == '\\') + ((c) == '=' || (c) == SETTINGS_SEPARATOR || (c) == '\\' || (c) == ' ') string_t *str; unsigned int i; @@ -2013,6 +2013,9 @@ const char *settings_section_escape(const char *name) case '\\': str_append(str, "\\\\"); break; + case ' ': + str_append(str, "\\_"); + break; default: str_append_c(str, name[i]); break;