From b748f91d0677fffaa2208b39ebb6db3aeb2e937b Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 5 Feb 2017 16:10:44 +0200 Subject: [PATCH] imap: Don't send empty FETCH () on failure It violates IMAP RFC. Send FETCH (UID n) instead. --- src/imap/imap-fetch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/imap/imap-fetch.c b/src/imap/imap-fetch.c index b4aea80b8a..fc54043715 100644 --- a/src/imap/imap-fetch.c +++ b/src/imap/imap-fetch.c @@ -526,6 +526,14 @@ static int imap_fetch_more_int(struct imap_fetch_context *ctx, bool cancel) i_stream_unref(&state->cur_input); } + if (state->cur_first) { + /* Writing FETCH () violates IMAP RFC. It's a bit + troublesome to delay flushing of "FETCH (" with + non-buffered data, so we'll just fix this by giving + UID as the response. */ + str_printfa(state->cur_str, "UID %u", + state->cur_mail->uid); + } if (str_len(state->cur_str) > 0) { /* no non-buffered handlers */ if (imap_fetch_flush_buffer(ctx) < 0) -- 2.47.3