From: Art Cancro Date: Tue, 18 Apr 2017 17:31:35 +0000 (-0400) Subject: Fix output of UID COPY operation X-Git-Tag: v939~555 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=3f857d71e2417964c394debca92b2b50f0e7c787 Fix output of UID COPY operation --- diff --git a/citadel/modules/imap/imap_misc.c b/citadel/modules/imap/imap_misc.c index e7940d1cb..39ae34b82 100644 --- a/citadel/modules/imap/imap_misc.c +++ b/citadel/modules/imap/imap_misc.c @@ -159,28 +159,25 @@ int imap_do_copy(const char *destination_folder) { * messages in our source room. Since the Citadel system uses UID's that * are both globally unique and persistent across a room-to-room copy, we * can get this done quite easily. - * - * FIXME this is outputing WRONG !!! See https://tools.ietf.org/html/rfc2359#section-4.3 */ void imap_output_copyuid_response(citimap *Imap) { int i; - int num_output = 0; - + StrBuf *MsgsCopied = NewStrBuf(); + for (i = 0; i < Imap->num_msgs; ++i) { if (Imap->flags[i] & IMAP_SELECTED) { - ++num_output; - if (num_output == 1) { - IAPuts("[COPYUID "); - } - else if (num_output > 1) { - IAPuts(","); + if (StrLength(MsgsCopied) > 0) { + StrBufAppendBufPlain(MsgsCopied, HKEY(","), 0); } - IAPrintf("%ld", Imap->msgids[i]); + StrBufAppendPrintf(MsgsCopied, "%ld", Imap->msgids[i]); } } - if (num_output > 0) { - IAPuts("] "); + + if (StrLength(MsgsCopied) > 0) { + IAPrintf("[COPYUID %ld %s %s] ", GLOBAL_UIDVALIDITY_VALUE, ChrPtr(MsgsCopied), ChrPtr(MsgsCopied)); } + + FreeStrBuf(&MsgsCopied); }