]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Allow section names to contain spaces.
authorTimo Sirainen <tss@iki.fi>
Tue, 6 Dec 2011 22:30:26 +0000 (00:30 +0200)
committerTimo Sirainen <tss@iki.fi>
Tue, 6 Dec 2011 22:30:26 +0000 (00:30 +0200)
src/config/config-parser.c
src/config/doveconf.c
src/lib-settings/settings-parser.c

index 7f85a02cf933f6b282cf51446faa62ff8d70d70e..3cfce8a6f0f3595c9887d35c2c50cb0fc5c5353d 100644 (file)
@@ -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 '='";
index b3e8b4af32cd6e8864d9bf6887cca19892da674d..7ff9eb45b64f3e2b878ae32b3962513645c7fc50 100644 (file)
@@ -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++;
 
index ee1206f06f75430754581b9546e8d66e81926b19..0ab60b1a5f2f0a85cdb2b7b2fcb8ce53a6de4730 100644 (file)
@@ -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;