From: Timo Sirainen Date: Sat, 26 Jul 2003 19:42:17 +0000 (+0300) Subject: Spaces are now stripped from end of line in config file. You can use " or ' X-Git-Tag: 1.1.alpha1~4459 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f8a5d2a09e90961d1d86dea294be162ccdb64a8;p=thirdparty%2Fdovecot%2Fcore.git Spaces are now stripped from end of line in config file. You can use " or ' quotes if you need them. --HG-- branch : HEAD --- diff --git a/dovecot-example.conf b/dovecot-example.conf index 2911a14e00..a442f52fad 100644 --- a/dovecot-example.conf +++ b/dovecot-example.conf @@ -55,8 +55,8 @@ #info_log_path = # Prefix for each line written to log file. % codes are in strftime(3) -# format. Note the extra space at the end of line. -#log_timestamp = %b %d %H:%M:%S +# format. +#log_timestamp = "%b %d %H:%M:%S " ## ## Login processes diff --git a/src/lib-settings/settings.c b/src/lib-settings/settings.c index f3731375d2..ded6bc358a 100644 --- a/src/lib-settings/settings.c +++ b/src/lib-settings/settings.c @@ -2,6 +2,7 @@ #include "lib.h" #include "istream.h" +#include "strescape.h" #include "settings.h" #include @@ -66,6 +67,7 @@ int settings_read(const char *path, const char *section, struct istream *input; const char *errormsg, *next_section; char *line, *key, *name; + size_t len; int fd, linenum, skip, sections, root_section; fd = open(path, O_RDONLY); @@ -99,7 +101,13 @@ int settings_read(const char *path, const char *section, if (*line == '#' || *line == '\0') continue; - /* a) "key = value" + /* remove whitespace from end of line */ + len = strlen(line); + while (IS_WHITE(line[len-1])) + len--; + line[len] = '\0'; + + /* a) key = value b) section_type section_name { c) } */ key = line; @@ -132,6 +140,14 @@ int settings_read(const char *path, const char *section, *line++ = '\0'; while (IS_WHITE(*line)) line++; + len = strlen(line); + if (len > 0 && + ((*line == '"' && line[len-1] == '"') || + (*line == '\'' && line[len-1] == '\''))) { + line[len-1] = '\0'; + line = str_unescape(line+1); + } + errormsg = skip ? NULL : callback(key, line, context); } else { @@ -147,7 +163,7 @@ int settings_read(const char *path, const char *section, line++; } - if (*line != '{' || strcspn(line+1, " \t") != 0) + if (*line != '{') errormsg = "Missing value"; else { sections++;