[evolution] I#176 - [Calendar] Incorrectly splits attendee name and email address



commit b0a4f6e9e745c28d1e3635ba26f92a1dee93490d
Author: Milan Crha <mcrha redhat com>
Date:   Tue Oct 16 15:08:49 2018 +0200

    I#176 - [Calendar] Incorrectly splits attendee name and email address
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/176

 src/addressbook/util/eab-book-util.c   | 29 +++++++++++++++++++++--------
 src/calendar/gui/e-meeting-list-view.c | 21 +++++++++++++++++----
 2 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/src/addressbook/util/eab-book-util.c b/src/addressbook/util/eab-book-util.c
index bd6d2187ef..3470f2d046 100644
--- a/src/addressbook/util/eab-book-util.c
+++ b/src/addressbook/util/eab-book-util.c
@@ -514,17 +514,30 @@ eab_parse_qp_email (const gchar *string,
 
        address = camel_header_address_decode (string, "UTF-8");
 
-       if (!address)
-               return FALSE;
+       if (address) {
+               /* report success only when we have filled both name and email address */
+               if (address->type == CAMEL_HEADER_ADDRESS_NAME && address->name && *address->name && 
address->v.addr && *address->v.addr) {
+                       *name = g_strdup (address->name);
+                       *email = g_strdup (address->v.addr);
+                       res = TRUE;
+               }
 
-       /* report success only when we have filled both name and email address */
-       if (address->type == CAMEL_HEADER_ADDRESS_NAME && address->name && *address->name && address->v.addr 
&& *address->v.addr) {
-               *name = g_strdup (address->name);
-               *email = g_strdup (address->v.addr);
-               res = TRUE;
+               camel_header_address_unref (address);
        }
 
-       camel_header_address_unref (address);
+       if (!res) {
+               CamelInternetAddress *addr = camel_internet_address_new ();
+               const gchar *const_name = NULL, *const_email = NULL;
+
+               if (camel_address_unformat (CAMEL_ADDRESS (addr), string) == 1 &&
+                   camel_internet_address_get (addr, 0, &const_name, &const_email)) {
+                       *name = (const_name && *const_name) ? g_strdup (const_name) : NULL;
+                       *email = (const_email && *const_email) ? g_strdup (const_email) : NULL;
+                       res = TRUE;
+               }
+
+               g_clear_object (&addr);
+       }
 
        return res;
 }
diff --git a/src/calendar/gui/e-meeting-list-view.c b/src/calendar/gui/e-meeting-list-view.c
index 8224bdf5d3..083d71f763 100644
--- a/src/calendar/gui/e-meeting-list-view.c
+++ b/src/calendar/gui/e-meeting-list-view.c
@@ -945,12 +945,25 @@ process_section (EMeetingListView *view,
                for (l = list_dests; l; l = l->next) {
                        EDestination *dest = l->data;
                        EContact *contact;
-                       const gchar *textrep;
                        gchar *fburi = NULL, *name = NULL, *email_addr = NULL;
 
-                       textrep = e_destination_get_textrep (dest, TRUE);
-                       if (!eab_parse_qp_email (textrep, &name, &email_addr))
-                               email_addr = g_strdup (textrep);
+                       email_addr = g_strdup (e_destination_get_email (dest));
+                       if (email_addr && *email_addr) {
+                               name = g_strdup (e_destination_get_name (dest));
+                               if (name && !*name) {
+                                       g_free (name);
+                                       name = NULL;
+                               }
+                       } else {
+                               const gchar *textrep;
+
+                               g_free (email_addr);
+                               email_addr = NULL;
+
+                               textrep = e_destination_get_textrep (dest, TRUE);
+                               if (!eab_parse_qp_email (textrep, &name, &email_addr))
+                                       email_addr = g_strdup (textrep);
+                       }
 
                        if (!email_addr || !*email_addr) {
                                g_free (name);


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