changeset 19555:d68d75446bcc

virtual plugin: Cleaned up behavior of '!' prefix with '+' and '-' 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.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 13 Jan 2016 13:46:33 +0200
parents fddcd9016d78
children ffa2c00dfd04
files src/plugins/virtual/virtual-config.c
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/virtual/virtual-config.c	Wed Jan 13 13:41:05 2016 +0200
+++ b/src/plugins/virtual/virtual-config.c	Wed Jan 13 13:46:33 2016 +0200
@@ -116,6 +116,7 @@
 {
 	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 @@
 		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 @@
 		}
 		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 */