[evolution-data-server] Bug 610919 - Remove superfluous space in flags in APPEND command



commit fab0477c103b348c9b567976b13b877b52534f7a
Author: David Woodhouse <David Woodhouse intel com>
Date:   Tue Jun 15 12:24:51 2010 +0100

    Bug 610919 - Remove superfluous space in flags in APPEND command
    
    RFC3501 doesn't permit a space between the final flag and the closing
    parenthesis, and Exchange will reject the command if it's there.

 camel/providers/imapx/camel-imapx-utils.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index 2c0965e..8ce6d48 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -138,6 +138,7 @@ imapx_write_flags(CamelStream *stream, guint32 flags, CamelFlag *user_flags, Cam
 /* throws IO exception */
 {
 	gint i;
+	gboolean first = TRUE;
 
 	if (camel_stream_write(stream, "(", 1) == -1) {
 		camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
@@ -148,30 +149,29 @@ imapx_write_flags(CamelStream *stream, guint32 flags, CamelFlag *user_flags, Cam
 		if (flag_table[i].flag & flags) {
 			if (flags & CAMEL_IMAPX_MESSAGE_RECENT)
 				continue;
-
+			if (!first && camel_stream_write(stream, " ", 1) == -1) {
+				camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
+				return;
+			}
+			first = FALSE;
 			if (camel_stream_write (stream, flag_table[i].name, strlen(flag_table[i].name)) == -1) {
 				camel_exception_setv (ex,1, "io error: %s", strerror(errno));
 				return;
 			}
 
 			flags &= ~flag_table[i].flag;
-			if (flags != 0 && user_flags == NULL)
-				if (camel_stream_write(stream, " ", 1) == -1) {
-					camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
-					return;
-				}
 		}
 	}
 
 	while (user_flags) {
 		const gchar *flag_name = rename_label_flag (user_flags->name, strlen (user_flags->name), FALSE);
 
-		if (camel_stream_write(stream, flag_name, strlen (flag_name)) == -1) {
+		if (!first && camel_stream_write(stream, " ", 1) == -1) {
 			camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
 			return;
 		}
-
-		if (user_flags->next && camel_stream_write(stream, " ", 1) == -1) {
+		first = FALSE;
+		if (camel_stream_write(stream, flag_name, strlen (flag_name)) == -1) {
 			camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
 			return;
 		}



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