Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8272:434a8a0edc0a HEAD
mbox: Fixed listing mailboxes in namespaces with prefix beginning with '~' or '/'.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 14 Oct 2008 00:58:13 +0300 |
parents | e18adf3003a4 |
children | 40df4d4cced0 |
files | src/lib-storage/list/mailbox-list-fs-iter.c |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-fs-iter.c Tue Oct 14 00:58:37 2008 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Tue Oct 14 00:58:13 2008 +0300 @@ -213,9 +213,10 @@ enum mailbox_list_iter_flags flags) { struct fs_list_iterate_context *ctx; - const char *path, *vpath, *rootdir; + const char *path, *vpath, *rootdir, *test_pattern; char *pattern; DIR *dirp; + unsigned int prefix_len; int ret; ctx = i_new(struct fs_list_iterate_context, 1); @@ -226,10 +227,20 @@ ctx->sep = (flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0 ? _list->ns->sep : _list->ns->real_sep; + prefix_len = strlen(_list->ns->prefix); i_array_init(&ctx->valid_patterns, 8); for (; *patterns != NULL; patterns++) { /* check that we're not trying to do any "../../" lists */ - if (mailbox_list_is_valid_pattern(_list, *patterns)) { + test_pattern = *patterns; + if ((flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0) { + /* skip namespace prefix if possible. this allows using + e.g. ~/mail/ prefix and have it pass the pattern + validation. */ + if (strncmp(test_pattern, _list->ns->prefix, + prefix_len) == 0) + test_pattern += prefix_len; + } + if (mailbox_list_is_valid_pattern(_list, test_pattern)) { if (strcasecmp(*patterns, "INBOX") == 0) { ctx->inbox_match = TRUE; continue;