don't let wildcards match INBOX, unless it lives under Path

it's counter-intuitive to have '*' match the (always present) INBOX
when the rest of the mailboxes lives in a different namespace.
This commit is contained in:
Oswald Buddenhagen 2013-04-13 19:05:27 +02:00
parent e7c96f8891
commit 406e967430
2 changed files with 24 additions and 19 deletions

View File

@ -706,28 +706,29 @@ store_opened( store_t *ctx, void *aux )
for (flags = 0, cpat = mvars->chan->patterns; cpat; cpat = cpat->next) { for (flags = 0, cpat = mvars->chan->patterns; cpat; cpat = cpat->next) {
const char *pat = cpat->string; const char *pat = cpat->string;
if (*pat != '!') { if (*pat != '!') {
int i; /* Partial matches like "INB*" or even "*" are not considered,
char c; * except implicity when the INBOX lives under Path. */
static const char strinbox[] = "INBOX"; if (!memcmp( pat, "INBOX", 5 )) {
for (i = 0; ; i++) { char c = pat[5];
c = pat[i]; if (!c) {
if (i == sizeof(strinbox) - 1) /* User really wants the INBOX. */
break; flags |= LIST_INBOX;
if (c != strinbox[i]) } else if (c == '/') {
goto nextpat; /* Flattened sub-folders of INBOX actually end up in Path. */
} if (ctx->conf->flat_delim)
if (!c) { flags |= LIST_PATH;
flags |= LIST_INBOX; else
} else if (c == '/') { flags |= LIST_INBOX;
if (ctx->conf->flat_delim) } else {
/* User may not want the INBOX after all ... */
flags |= LIST_PATH; flags |= LIST_PATH;
else /* ... but maybe he does.
flags |= LIST_INBOX; * The flattened sub-folder case is implicitly covered by the previous line. */
if (c == '*' || c == '%')
flags |= LIST_INBOX;
}
} else { } else {
nextpat:
flags |= LIST_PATH; flags |= LIST_PATH;
if (c == '*' || c == '%')
flags |= LIST_INBOX;
} }
} }
} }

View File

@ -370,6 +370,10 @@ and \fB%\fR matches anything up to the next hierarchy delimiter. Prepending
\fB!\fR to a pattern makes it an exclusion. Multiple patterns can be specified \fB!\fR to a pattern makes it an exclusion. Multiple patterns can be specified
(either by supplying multiple arguments or by using \fBPattern\fR multiple (either by supplying multiple arguments or by using \fBPattern\fR multiple
times); later matches take precedence. times); later matches take precedence.
.br
Note that \fBINBOX\fR is not matched by wildcards, unless it lives under
\fBPath\fR.
.br
Example: "\fBPatterns\fR\ \fI%\ !Trash\fR" Example: "\fBPatterns\fR\ \fI%\ !Trash\fR"
.. ..
.TP .TP