Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9502:91c6b067f464 HEAD
expire: Settings now support spaces in mailbox names by using quoted strings.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 09 Dec 2009 19:44:35 -0500 |
parents | f1c4c0c90da1 |
children | 8d4621094e54 |
files | src/plugins/expire/expire-env.c |
diffstat | 1 files changed, 41 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/expire/expire-env.c Wed Dec 09 18:58:13 2009 -0500 +++ b/src/plugins/expire/expire-env.c Wed Dec 09 19:44:35 2009 -0500 @@ -2,6 +2,8 @@ #include "lib.h" #include "array.h" +#include "str.h" +#include "strescape.h" #include "imap-match.h" #include "expire-env.h" @@ -25,6 +27,34 @@ ARRAY_DEFINE(expire_boxes, struct expire_box); }; +static const char *quoted_string_get(char *const **namesp) +{ + string_t *str = t_str_new(128); + char *const *names = *namesp; + const char *name; + unsigned int i; + + name = (*names) + 1; + for (;;) { + for (i = 0; name[i] != '\0'; i++) { + if (name[i] == '\\' && + name[i+1] != '\0') + i++; + else if (name[i] == '"') + break; + } + str_append_unescaped(str, name, i); + names++; + if (name[i] == '"' || *names == NULL) + break; + + str_append_c(str, ' '); + name = *names; + } + *namesp = names; + return str_c(str); +} + static void expire_env_parse(struct expire_env *env, const char *str, enum expire_type type) { @@ -39,17 +69,23 @@ len = str_array_length((const char *const *)names); p_array_init(&env->expire_boxes, env->pool, len / 2); - for (; *names != NULL; names += 2) { - if (names[1] == NULL) { + for (; *names != NULL; names++) { + if (**names == '"') { + /* quoted string. */ + box.pattern = quoted_string_get(&names); + } else { + box.pattern = *names; + names++; + } + if (*names == NULL) { i_fatal("expire: Missing expire days for mailbox '%s'", - *names); + box.pattern); } - box.pattern = *names; /* FIXME: hardcoded separator isn't very good */ box.glob = imap_match_init(env->pool, box.pattern, TRUE, '/'); box.type = type; - box.expire_secs = strtoul(names[1], NULL, 10) * 3600 * 24; + box.expire_secs = strtoul(*names, NULL, 10) * 3600 * 24; if (getenv("DEBUG") != NULL) { i_info("expire: pattern=%s type=%s secs=%u",