[evolution-data-server/gnome-40] I#323 - Camel: Consider plain words as message ids in In-Reply-To/References headers



commit 959ee33dde38f45d207b419c1e3c16f9a8be9851
Author: Milan Crha <mcrha redhat com>
Date:   Wed Apr 14 11:28:01 2021 +0200

    I#323 - Camel: Consider plain words as message ids in In-Reply-To/References headers
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/323

 src/camel/camel-mime-utils.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/camel/camel-mime-utils.c b/src/camel/camel-mime-utils.c
index 31024f5d4..25a626d8e 100644
--- a/src/camel/camel-mime-utils.c
+++ b/src/camel/camel-mime-utils.c
@@ -3131,6 +3131,7 @@ static void
 header_references_decode_single (const gchar **in, GSList **list)
 {
        const gchar *inptr = *in;
+       GString *accum_word = NULL;
        gchar *id, *word;
 
        while (*inptr) {
@@ -3143,13 +3144,35 @@ header_references_decode_single (const gchar **in, GSList **list)
                        }
                } else {
                        word = header_decode_word (&inptr);
-                       if (word)
+                       if (word) {
+                               /* To support broken clients, which do not enclose message IDs into angle 
brackets, as
+                                  required in the RFC 2822: 
https://tools.ietf.org/html/rfc2822#section-3.6.4 */
+                               if (!*inptr || camel_mime_is_lwsp (*inptr)) {
+                                       if (accum_word) {
+                                               g_string_append (accum_word, word);
+                                               *list = g_slist_prepend (*list, g_string_free (accum_word, 
FALSE));
+                                               accum_word = NULL;
+                                       } else {
+                                               *list = g_slist_prepend (*list, word);
+                                               word = NULL;
+                                       }
+                               } else {
+                                       if (accum_word)
+                                               g_string_append (accum_word, word);
+                                       else
+                                               accum_word = g_string_new (word);
+
+                                       g_string_append_c (accum_word, *inptr);
+                               }
                                g_free (word);
-                       else if (*inptr != '\0')
+                       } else if (*inptr != '\0')
                                inptr++; /* Stupid mailer tricks */
                }
        }
 
+       if (accum_word)
+               *list = g_slist_prepend (*list, g_string_free (accum_word, FALSE));
+
        *in = inptr;
 }
 


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