commit bdb17fb9c3b592bc296286090b403e25622b0471
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Sat Apr 13 19:05:27 2013 +0200

    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.

 src/main.c   |   39 ++++++++++++++++++++-------------------
 src/mbsync.1 |    4 ++++
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/src/main.c b/src/main.c
index 79b39e0..741107c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -706,28 +706,29 @@ store_opened( store_t *ctx, void *aux )
                for (flags = 0, cpat = mvars->chan->patterns; cpat; cpat = 
cpat->next) {
                        const char *pat = cpat->string;
                        if (*pat != '!') {
-                               int i;
-                               char c;
-                               static const char strinbox[] = "INBOX";
-                               for (i = 0; ; i++) {
-                                       c = pat[i];
-                                       if (i == sizeof(strinbox) - 1)
-                                               break;
-                                       if (c != strinbox[i])
-                                               goto nextpat;
-                               }
-                               if (!c) {
-                                       flags |= LIST_INBOX;
-                               } else if (c == '/') {
-                                       if (ctx->conf->flat_delim)
-                                               flags |= LIST_PATH;
-                                       else
+                               /* Partial matches like "INB*" or even "*" are 
not considered,
+                                * except implicity when the INBOX lives under 
Path. */
+                               if (!memcmp( pat, "INBOX", 5 )) {
+                                       char c = pat[5];
+                                       if (!c) {
+                                               /* User really wants the INBOX. 
*/
                                                flags |= LIST_INBOX;
+                                       } else if (c == '/') {
+                                               /* Flattened sub-folders of 
INBOX actually end up in Path. */
+                                               if (ctx->conf->flat_delim)
+                                                       flags |= LIST_PATH;
+                                               else
+                                                       flags |= LIST_INBOX;
+                                       } else {
+                                               /* User may not want the INBOX 
after all ... */
+                                               flags |= LIST_PATH;
+                                               /* ... but maybe he does.
+                                                * The flattened sub-folder 
case is implicitly covered by the previous line. */
+                                               if (c == '*' || c == '%')
+                                                       flags |= LIST_INBOX;
+                                       }
                                } else {
-                                 nextpat:
                                        flags |= LIST_PATH;
-                                       if (c == '*' || c == '%')
-                                               flags |= LIST_INBOX;
                                }
                        }
                }
diff --git a/src/mbsync.1 b/src/mbsync.1
index b57e9da..8dd8c69 100644
--- a/src/mbsync.1
+++ b/src/mbsync.1
@@ -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
 (either by supplying multiple arguments or by using \fBPattern\fR multiple
 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"
 ..
 .TP

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to