changeset 21946:dd009c471bd2

lib-imap: imap-bodystructure: Fixed handling of a multipart part without children in imap_bodystructure_write(). In that case it writes an empty text/plain part to prevent generating an invalid BODYSTRUCURE. However, it always generated the basic BODY version without the extra fields for a full BODYSTRUCTURE.
author Stephan Bosch <stephan.bosch@dovecot.fi>
date Wed, 12 Apr 2017 10:13:15 +0200
parents 58504d6c66d2
children f98d4d45e16e
files src/lib-imap/imap-bodystructure.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap/imap-bodystructure.c	Tue Apr 11 20:32:19 2017 +0300
+++ b/src/lib-imap/imap-bodystructure.c	Wed Apr 12 10:13:15 2017 +0200
@@ -13,8 +13,11 @@
 #include "imap-envelope.h"
 #include "imap-bodystructure.h"
 
+#define EMPTY_BODY "(\"text\" \"plain\" " \
+	"(\"charset\" \""MESSAGE_PART_DEFAULT_CHARSET"\") NIL NIL \"7bit\" 0 0)"
 #define EMPTY_BODYSTRUCTURE "(\"text\" \"plain\" " \
-	"(\"charset\" \""MESSAGE_PART_DEFAULT_CHARSET"\") NIL NIL \"7bit\" 0 0)"
+	"(\"charset\" \""MESSAGE_PART_DEFAULT_CHARSET"\") NIL NIL \"7bit\" 0 0 " \
+		"NIL NIL NIL NIL)"
 
 /*
  * IMAP BODY/BODYSTRUCTURE write
@@ -118,7 +121,10 @@
 		/* no parts in multipart message,
 		   that's not allowed. write a single
 		   0-length text/plain structure */
-		str_append(str, EMPTY_BODYSTRUCTURE);
+		if (!extended)
+			str_append(str, EMPTY_BODY);
+		else
+			str_append(str, EMPTY_BODYSTRUCTURE);
 	}
 
 	str_append_c(str, ' ');