From 32392adbe3fd349e18d282a4e73208c32d6bfd1b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sun, 14 Feb 2021 21:25:26 +0100 Subject: [PATCH] accept unsolicited FETCH responses (without payload) after all while the spec says that the server SHOULD not send FETCH responses about STORE FLAGS when .SILENT is used, at least gmail and fastmail seem to do it nonetheless. also, in case of concurrent flag updates on the affected messages such responses can be legitimately sent. in earlier versions of mbsync this would lead to duplicate messages piling up in the store, though that would pose no problem at that point. --- src/drv_imap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index 9f23e08..c270031 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -1181,7 +1181,8 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s ATTR_UNUSED ) for (cmdp = ctx->in_progress; cmdp; cmdp = cmdp->next) if (cmdp->param.uid == uid) goto gotuid; - goto badrsp; + error( "IMAP error: unexpected FETCH response with BODY (UID %u)\n", uid ); + return LIST_BAD; gotuid: msgdata = ((imap_cmd_fetch_msg_t *)cmdp)->msg_data; msgdata->data = body->val; @@ -1208,9 +1209,8 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s ATTR_UNUSED ) memcpy( cur->tuid, tuid, TUIDL ); status &= ~(M_FLAGS | M_RECENT | M_SIZE | M_HEADER); } else { - badrsp: - error( "IMAP error: unexpected FETCH response (UID %u)\n", uid ); - return LIST_BAD; + // These may come in as a result of STORE FLAGS despite .SILENT. + status &= ~(M_FLAGS | M_RECENT); } if (status) {