[evolution-mapi] Do not add extra \0 at the end of text mail message bodies



commit 1172bf31258765c29ea67a9600784a8e0411c0bf
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 8 08:17:05 2011 +0100

    Do not add extra \0 at the end of text mail message bodies

 src/libexchangemapi/exchange-mapi-mail-utils.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/src/libexchangemapi/exchange-mapi-mail-utils.c b/src/libexchangemapi/exchange-mapi-mail-utils.c
index 9af7a9b..323a132 100644
--- a/src/libexchangemapi/exchange-mapi-mail-utils.c
+++ b/src/libexchangemapi/exchange-mapi-mail-utils.c
@@ -483,6 +483,7 @@ mapi_mime_msg_body (MailItem *item, const ExchangeMAPIStream *body)
 	if (body && body->value && body->value->len > 0) {
 		const gchar *type = NULL;
 		gchar *buff = NULL;
+		gboolean strip_last_null;
 
 		if (item->is_cal)
 			type = "text/calendar";
@@ -508,7 +509,8 @@ mapi_mime_msg_body (MailItem *item, const ExchangeMAPIStream *body)
 			type = buff;
 		}
 
-		camel_mime_part_set_content (part, (const gchar *) body->value->data, body->value->len, type);
+		strip_last_null = body->value->len > 0 && body->value->data[body->value->len - 1] == '\0';
+		camel_mime_part_set_content (part, (const gchar *) body->value->data, body->value->len + (strip_last_null ? -1 : 0), type);
 
 		g_free (buff);
 	} else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]