[evolution-data-server/gnome-3-28] Make sure errors reported from backends are valid UTF-8 strings



commit 729c8d49798c3a3215944772a43531910bcc5387
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jul 3 14:16:08 2018 +0200

    Make sure errors reported from backends are valid UTF-8 strings
    
    At least the EBookCache can store non-UTF-8 values into the database
    within the INSERT statement, which require conversion to UTF-8,
    otherwise an "[Invalid UTF-8]" error is shown on the client side instead.

 src/addressbook/libedata-book/e-data-book.c | 8 +++++++-
 src/calendar/libedata-cal/e-data-cal.c      | 8 +++++++-
 src/libebackend/e-cache.c                   | 5 ++++-
 3 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/addressbook/libedata-book/e-data-book.c b/src/addressbook/libedata-book/e-data-book.c
index f851a3891..a99ef4d3c 100644
--- a/src/addressbook/libedata-book/e-data-book.c
+++ b/src/addressbook/libedata-book/e-data-book.c
@@ -1789,10 +1789,16 @@ void
 e_data_book_report_error (EDataBook *book,
                           const gchar *message)
 {
+       gchar *valid_utf8;
+
        g_return_if_fail (E_IS_DATA_BOOK (book));
        g_return_if_fail (message != NULL);
 
-       e_dbus_address_book_emit_error (book->priv->dbus_interface, message);
+       valid_utf8 = e_util_utf8_make_valid (message);
+
+       e_dbus_address_book_emit_error (book->priv->dbus_interface, valid_utf8 ? valid_utf8 : message);
+
+       g_free (valid_utf8);
 }
 
 /**
diff --git a/src/calendar/libedata-cal/e-data-cal.c b/src/calendar/libedata-cal/e-data-cal.c
index 4144db938..a1c052bf7 100644
--- a/src/calendar/libedata-cal/e-data-cal.c
+++ b/src/calendar/libedata-cal/e-data-cal.c
@@ -2379,10 +2379,16 @@ void
 e_data_cal_report_error (EDataCal *cal,
                          const gchar *message)
 {
+       gchar *valid_utf8;
+
        g_return_if_fail (E_IS_DATA_CAL (cal));
        g_return_if_fail (message != NULL);
 
-       e_dbus_calendar_emit_error (cal->priv->dbus_interface, message);
+       valid_utf8 = e_util_utf8_make_valid (message);
+
+       e_dbus_calendar_emit_error (cal->priv->dbus_interface, valid_utf8 ? valid_utf8 : message);
+
+       g_free (valid_utf8);
 }
 
 /**
diff --git a/src/libebackend/e-cache.c b/src/libebackend/e-cache.c
index e683da119..c5fd89c13 100644
--- a/src/libebackend/e-cache.c
+++ b/src/libebackend/e-cache.c
@@ -39,6 +39,7 @@
 #include <glib/gstdio.h>
 
 #include <camel/camel.h>
+#include <libedataserver/libedataserver.h>
 
 #include "e-sqlite3-vfs.h"
 
@@ -510,8 +511,10 @@ e_cache_column_info_free (gpointer info)
                } else if (code == SQLITE_ABORT || code == SQLITE_INTERRUPT) { \
                        g_set_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Operation cancelled: %s", 
message); \
                } else { \
+                       gchar *valid_utf8 = e_util_utf8_make_valid (stmt); \
                        g_set_error (error, E_CACHE_ERROR, E_CACHE_ERROR_ENGINE, \
-                               "SQLite error code '%d': %s (statement:%s)", code, message, stmt); \
+                               "SQLite error code '%d': %s (statement:%s)", code, message, valid_utf8 ? 
valid_utf8 : stmt); \
+                       g_free (valid_utf8); \
                } \
        } G_STMT_END
 


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