dovecot-2.1: config: Allow section names to contain spaces.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Dec 7 00:30:31 EET 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/2adcc2b87117
changeset: 13803:2adcc2b87117
user: Timo Sirainen <tss at iki.fi>
date: Wed Dec 07 00:30:26 2011 +0200
description:
config: Allow section names to contain spaces.
diffstat:
src/config/config-parser.c | 25 ++++++++++++++++++-------
src/config/doveconf.c | 8 ++++++--
src/lib-settings/settings-parser.c | 5 ++++-
3 files changed, 28 insertions(+), 10 deletions(-)
diffs (76 lines):
diff -r 2c8d39467f21 -r 2adcc2b87117 src/config/config-parser.c
--- a/src/config/config-parser.c Tue Dec 06 23:55:48 2011 +0200
+++ b/src/config/config-parser.c Wed Dec 07 00:30:26 2011 +0200
@@ -642,14 +642,25 @@
*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 -r 2c8d39467f21 -r 2adcc2b87117 src/config/doveconf.c
--- a/src/config/doveconf.c Tue Dec 06 23:55:48 2011 +0200
+++ b/src/config/doveconf.c Wed Dec 07 00:30:26 2011 +0200
@@ -270,8 +270,12 @@
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 -r 2c8d39467f21 -r 2adcc2b87117 src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c Tue Dec 06 23:55:48 2011 +0200
+++ b/src/lib-settings/settings-parser.c Wed Dec 07 00:30:26 2011 +0200
@@ -1989,7 +1989,7 @@
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 @@
case '\\':
str_append(str, "\\\\");
break;
+ case ' ':
+ str_append(str, "\\_");
+ break;
default:
str_append_c(str, name[i]);
break;
More information about the dovecot-cvs
mailing list