From: David Woodhouse Date: Tue, 15 Jun 2010 11:24:51 +0000 (+0100) Subject: Bug 610919 - Remove superfluous space in flags in APPEND command X-Git-Tag: upstream/3.7.4~2999 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fab0477c103b348c9b567976b13b877b52534f7a;p=platform%2Fupstream%2Fevolution-data-server.git 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. --- 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; }