From c8b73acad2a3c698d82ab52d239fd86b48c50c8e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 3 Feb 2021 14:25:44 +0100 Subject: [PATCH 1/2] unbreak handling of 'INBOX.' NAMESPACE again INBOX matching must not prevent prefix (namespace) stripping, as INBOX may be the namespace. amends 04fc586e7. REFMAIL: 186391612191752@vla1-ea7e194e8506.qloud-c.yandex.net --- src/drv_imap.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index fbf3072..810479e 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -1268,13 +1268,14 @@ parse_list_rsp_p2( imap_store_t *ctx, list_t *list, char *cmd ATTR_UNUSED ) } arg = list->val; argl = list->len; - if (is_inbox( ctx, arg, argl )) { - // The server might be weird and have a non-uppercase INBOX. It - // may legitimately do so, but we need the canonical spelling. - memcpy( arg, "INBOX", 5 ); - } else if ((l = strlen( ctx->prefix ))) { - if (!starts_with( arg, argl, ctx->prefix, l )) + if ((l = strlen( ctx->prefix ))) { + if (!starts_with( arg, argl, ctx->prefix, l )) { + if (is_inbox( ctx, arg, argl )) { + // INBOX and its subfolders bypass the namespace. + goto inbox; + } goto skip; + } arg += l; argl -= l; // A folder named "INBOX" would be indistinguishable from the @@ -1286,6 +1287,14 @@ parse_list_rsp_p2( imap_store_t *ctx, list_t *list, char *cmd ATTR_UNUSED ) warn( "IMAP warning: ignoring INBOX in %s\n", ctx->prefix ); goto skip; } + } else if (is_inbox( ctx, arg, argl )) { + inbox: + // The server might be weird and have a non-uppercase INBOX. It + // may legitimately do so, but we need the canonical spelling. + // Note that we do that only after prefix matching, under the + // assumption that the NAMESPACE (or Path) matches the + // capitalization of LIST. + memcpy( arg, "INBOX", 5 ); } if (argl >= 5 && !memcmp( arg + argl - 5, ".lock", 5 )) /* workaround broken servers */ goto skip; From e4eac03a9a2f4494840e4980603a47dc6f3c17e5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 3 Feb 2021 14:44:31 +0100 Subject: [PATCH 2/2] bump version --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 188d712..9b603af 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([isync], [1.3.3]) +AC_INIT([isync], [1.3.4]) AC_CONFIG_HEADERS([autodefs.h]) AM_INIT_AUTOMAKE