[evolution/gnome-2-28] Bug #606340 - Crash on non-utf8 letter in mail folder name
- From: Milan Crha <mcrha src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution/gnome-2-28] Bug #606340 - Crash on non-utf8 letter in mail folder name
- Date: Thu, 7 Jan 2010 20:04:07 +0000 (UTC)
commit 4aae323f2db2b3106376fb1b5f09e24e960f6763
Author: Milan Crha <mcrha redhat com>
Date: Thu Jan 7 21:02:16 2010 +0100
Bug #606340 - Crash on non-utf8 letter in mail folder name
widgets/misc/e-info-label.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/widgets/misc/e-info-label.c b/widgets/misc/e-info-label.c
index 3333d47..31d7da8 100644
--- a/widgets/misc/e-info-label.c
+++ b/widgets/misc/e-info-label.c
@@ -194,6 +194,23 @@ e_info_label_new(const gchar *icon)
return (GtkWidget *)el;
}
+static gchar *
+ensure_utf8 (const gchar *text)
+{
+ gchar *res = g_strdup (text), *p;
+
+ if (!text)
+ return res;
+
+ p = res;
+ while (!g_utf8_validate (p, -1, (const gchar **) &p)) {
+ /* make all invalid characters appear as question marks */
+ *p = '?';
+ }
+
+ return res;
+}
+
/**
* e_info_label_set_info:
* @el:
@@ -210,6 +227,7 @@ void
e_info_label_set_info(EInfoLabel *el, const gchar *location, const gchar *info)
{
gchar *markup;
+ gchar *tmp;
if (el->location == NULL) {
el->location = gtk_label_new (NULL);
@@ -235,12 +253,15 @@ e_info_label_set_info(EInfoLabel *el, const gchar *location, const gchar *info)
gtk_widget_set_state (GTK_WIDGET (el), GTK_STATE_ACTIVE);
}
- markup = g_markup_printf_escaped ("<b>%s</b>", location);
+ tmp = ensure_utf8 (location);
+ markup = g_markup_printf_escaped ("<b>%s</b>", tmp);
gtk_label_set_markup (GTK_LABEL (el->location), markup);
g_free (markup);
+ g_free (tmp);
- markup = g_markup_printf_escaped ("<small>%s</small>", info);
+ tmp = ensure_utf8 (info);
+ markup = g_markup_printf_escaped ("<small>%s</small>", tmp);
gtk_label_set_markup (GTK_LABEL (el->info), markup);
g_free (markup);
+ g_free (tmp);
}
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]