]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap-client: Handle better when QRESYNC capable server doesn't send CLOSED imap...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 22 Apr 2024 08:05:09 +0000 (11:05 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 3 May 2024 07:34:35 +0000 (10:34 +0300)
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.

src/lib-imap-client/imapc-connection.c

index dd1ea22df1d4c25213a1343b8deed711fcb2596f..30e8afef025474278ad29b8d2af5b04282cab620 100644 (file)
@@ -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);