]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
virtual plugin: Cleaned up behavior of '!' prefix with '+' and '-'
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Jan 2016 11:46:33 +0000 (13:46 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Jan 2016 11:46:33 +0000 (13:46 +0200)
It makes a bit more sense now. Mainly the difference is that "!foo*" means
to save mails to a mailbox called "foo*", instead of including mailboxes
matching "!foo*" pattern to the virtual mailbox. It's unlikely anyone was
relying on this behavior.

src/plugins/virtual/virtual-config.c

index d47c43c5a88cd0a5ebf9a5b464c97c24b03caf04..9e88695efef897b335f8b244320db3fc8f56130d 100644 (file)
@@ -116,6 +116,7 @@ virtual_config_parse_line(struct virtual_parse_context *ctx, const char *line,
 {
        struct mail_user *user = ctx->mbox->storage->storage.user;
        struct virtual_backend_box *bbox;
+       bool no_wildcards = FALSE;
 
        if (*line == ' ' || *line == '\t') {
                /* continues the previous search rule */
@@ -155,13 +156,7 @@ virtual_config_parse_line(struct virtual_parse_context *ctx, const char *line,
                bbox->name++;
                bbox->negative_match = TRUE;
                break;
-       }
-
-       if (strchr(bbox->name, '*') != NULL ||
-           strchr(bbox->name, '%') != NULL) {
-               bbox->glob = imap_match_init(ctx->pool, bbox->name, TRUE, ctx->sep);
-               ctx->have_wildcards = TRUE;
-       } else if (bbox->name[0] == '!') {
+       case '!':
                /* save messages here */
                if (ctx->mbox->save_bbox != NULL) {
                        *error_r = "Multiple save mailboxes defined";
@@ -169,6 +164,15 @@ virtual_config_parse_line(struct virtual_parse_context *ctx, const char *line,
                }
                bbox->name++;
                ctx->mbox->save_bbox = bbox;
+               no_wildcards = TRUE;
+               break;
+       }
+
+       if (!no_wildcards &&
+           (strchr(bbox->name, '*') != NULL ||
+            strchr(bbox->name, '%') != NULL)) {
+               bbox->glob = imap_match_init(ctx->pool, bbox->name, TRUE, ctx->sep);
+               ctx->have_wildcards = TRUE;
        }
        /* now that the prefix characters have been processed,
           find the namespace */