changeset 21493:f2d8b1c3773e

imap: Don't send empty FETCH () on failure It violates IMAP RFC. Send FETCH (UID n) instead.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Feb 2017 16:10:44 +0200
parents c0f9d3f9bfd0
children 6291f52aea85
files src/imap/imap-fetch.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-fetch.c	Mon Feb 06 11:02:46 2017 +0200
+++ b/src/imap/imap-fetch.c	Sun Feb 05 16:10:44 2017 +0200
@@ -528,6 +528,14 @@
 				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)