From 3f857d71e2417964c394debca92b2b50f0e7c787 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 18 Apr 2017 13:31:35 -0400 Subject: [PATCH] Fix output of UID COPY operation --- citadel/modules/imap/imap_misc.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) 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); } -- 2.30.2