[evolution-ews] Bug 794815 - Forgive errors when fetching events



commit 7935a22f4f0fee3e9dc07a5096003c1a9a826bee
Author: Milan Crha <mcrha redhat com>
Date:   Mon Apr 9 10:37:12 2018 +0200

    Bug 794815 - Forgive errors when fetching events

 src/calendar/e-cal-backend-ews.c |    9 +++++++--
 src/server/e-ews-item.c          |   17 +++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 4430a13..f4371a9 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -578,7 +578,7 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
 
                if (!vcomp) {
                        if (mime_content)
-                               g_warn_if_reached ();
+                               g_warning ("%s: Failed to parse mime content:---%s---", G_STRFUNC, 
mime_content);
                        return NULL;
                }
 
@@ -1109,9 +1109,14 @@ ecb_ews_get_items_sync (ECalBackendEws *cbews,
                        break;
                } else {
                        ECalComponent *comp;
+                       GError *local_error = NULL;
 
-                       comp = ecb_ews_item_to_component_sync (cbews, item, cancellable, error);
+                       comp = ecb_ews_item_to_component_sync (cbews, item, cancellable, &local_error);
                        if (!comp) {
+                               if (!local_error)
+                                       continue;
+
+                               g_propagate_error (error, local_error);
                                success = FALSE;
                                break;
                        }
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index a5b99bf..88c75a8 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -30,6 +30,8 @@
 #include <glib/gprintf.h>
 #include <libsoup/soup-misc.h>
 #include <libical/ical.h>
+#include <libedataserver/libedataserver.h>
+
 #include "e-ews-item.h"
 #include "e-ews-item-change.h"
 
@@ -1512,6 +1514,7 @@ e_ews_item_set_from_soap_parameter (EEwsItem *item,
 
                /* The order is maintained according to the order in soap response */
                if (!g_ascii_strcasecmp (name, "MimeContent")) {
+                       gchar *charset;
                        guchar *data;
                        gsize data_len = 0;
 
@@ -1522,6 +1525,20 @@ e_ews_item_set_from_soap_parameter (EEwsItem *item,
                                g_free (data);
                                return FALSE;
                        }
+
+                       charset = e_soap_parameter_get_property (subparam, "CharacterSet");
+                       if (g_strcmp0 (charset, "UTF-8") == 0 &&
+                           !g_utf8_validate ((const gchar *) data, data_len, NULL)) {
+                               gchar *tmp;
+
+                               tmp = e_util_utf8_data_make_valid ((const gchar *) data, data_len);
+                               if (tmp) {
+                                       g_free (data);
+                                       data = (guchar *) tmp;
+                               }
+                       }
+                       g_free (charset);
+
                        priv->mime_content = (gchar *) data;
 
                        g_free (value);


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