[evolution-data-server/gnome-3-20] Bug 767780 - The "References" header folded twice



commit a614b3691a0537a81d43dc16cc61d02436bd1dcb
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jun 21 10:23:44 2016 +0200

    Bug 767780 - The "References" header folded twice

 camel/camel-mime-part.c |   40 +++++++++++++++++++++++-----------------
 1 files changed, 23 insertions(+), 17 deletions(-)
---
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index ff9859f..e8e452d 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -170,26 +170,32 @@ write_references (gpointer stream,
        if (!isspace (value[0]))
                g_string_append_c (buffer, ' ');
 
-       len = buffer->len;
+       /* Fold only when not folded already */
+       if (!strchr (value, '\n')) {
+               len = buffer->len;
+
+               while (*value) {
+                       ids = value;
+                       ide = strchr (ids + 1, '>');
+                       if (ide)
+                               value = ++ide;
+                       else
+                               ide = value = strlen (ids) + ids;
 
-       while (*value) {
-               ids = value;
-               ide = strchr (ids + 1, '>');
-               if (ide)
-                       value = ++ide;
-               else
-                       ide = value = strlen (ids) + ids;
+                       if (len > 0 && len + (ide - ids) >= CAMEL_FOLD_SIZE) {
+                               g_string_append_len (buffer, "\n\t", 2);
+                               len = 0;
+                       }
 
-               if (len > 0 && len + (ide - ids) >= CAMEL_FOLD_SIZE) {
-                       g_string_append_len (buffer, "\n\t", 2);
-                       len = 0;
+                       g_string_append_len (buffer, ids, ide - ids);
+                       len += (ide - ids);
                }
-
-               g_string_append_len (buffer, ids, ide - ids);
-               len += (ide - ids);
+       } else {
+               g_string_append (buffer, value);
        }
 
-       g_string_append_c (buffer, '\n');
+       if (buffer->len > 0 && buffer->str[buffer->len - 1] != '\n')
+               g_string_append_c (buffer, '\n');
 
        /* XXX For now we handle both types of streams. */
 


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