From: Timo Sirainen Date: Mon, 22 Apr 2024 08:05:09 +0000 (+0300) Subject: lib-imap-client: Handle better when QRESYNC capable server doesn't send CLOSED imap... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b299ee4c1b7a391b47b9bf53cbb8666481f549c8;p=thirdparty%2Fdovecot%2Fcore.git lib-imap-client: Handle better when QRESYNC capable server doesn't send CLOSED imap-resp-code QRESYNC RFC specifies that the [CLOSED] imap-resp-code MUST always be sent if server advertises CONDSTORE or QRESYNC capability. However, at least some Zimbra versions don't do this. Workaround by reconnecting to the server automatically. --- diff --git a/src/lib-imap-client/imapc-connection.c b/src/lib-imap-client/imapc-connection.c index dd1ea22df1..30e8afef02 100644 --- a/src/lib-imap-client/imapc-connection.c +++ b/src/lib-imap-client/imapc-connection.c @@ -1540,6 +1540,21 @@ static int imapc_connection_input_tagged(struct imapc_connection *conn) /* we've successfully received replies to some commands. */ conn->reconnect_ok = TRUE; } + + if (reply.state == IMAPC_COMMAND_STATE_OK && + (cmd->flags & IMAPC_COMMAND_FLAG_SELECT) != 0 && + conn->qresync_selecting_box != NULL) { + /* Put the command back to the waiting list, since we're not + actually going to finish handling it here. */ + array_push_back(&conn->cmd_wait_list, &cmd); + /* Work around the problem by reconnecting - there is no + selected folder then. */ + conn->qresync_selecting_box->reconnect_ok = TRUE; + imapc_connection_try_reconnect(conn, + "QRESYNC capable server didn't send [CLOSED] in untagged reply after SELECT", + 0, FALSE); + return -1; + } imapc_connection_input_reset(conn); imapc_command_reply_free(cmd, &reply); imapc_command_send_more(conn);