aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-10-01 15:53:36 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-10-01 15:53:36 +0800
commitbde8fac84db075ab8010352cccb4f59b3127ca9c (patch)
tree915bca38f224f654b53d2827b569247f0907400a /plugins
parentaae003381abb042726c16b7013d869644df13e95 (diff)
downloadgsoc2013-evolution-bde8fac84db075ab8010352cccb4f59b3127ca9c.tar
gsoc2013-evolution-bde8fac84db075ab8010352cccb4f59b3127ca9c.tar.gz
gsoc2013-evolution-bde8fac84db075ab8010352cccb4f59b3127ca9c.tar.bz2
gsoc2013-evolution-bde8fac84db075ab8010352cccb4f59b3127ca9c.tar.lz
gsoc2013-evolution-bde8fac84db075ab8010352cccb4f59b3127ca9c.tar.xz
gsoc2013-evolution-bde8fac84db075ab8010352cccb4f59b3127ca9c.tar.zst
gsoc2013-evolution-bde8fac84db075ab8010352cccb4f59b3127ca9c.zip
** Fix for bug #519491
2008-10-01 Milan Crha <mcrha@redhat.com> ** Fix for bug #519491 * itip-view.c: (ensure_utf8), (itip_view_set_organizer), (itip_view_set_organizer_sentby), (itip_view_set_attendee), (itip_view_set_attendee_sentby), (itip_view_set_proxy), (itip_view_set_delegator), (itip_view_set_summary), (itip_view_set_location), (itip_view_set_status), (itip_view_set_comment), (itip_view_set_description), (itip_view_add_upper_info_item), (itip_view_add_lower_info_item): Convert texts to valid UTF-8 texts before passing them to Gtk+ functions which requires that. svn path=/trunk/; revision=36516
Diffstat (limited to 'plugins')
-rw-r--r--plugins/itip-formatter/ChangeLog14
-rw-r--r--plugins/itip-formatter/itip-view.c44
2 files changed, 45 insertions, 13 deletions
diff --git a/plugins/itip-formatter/ChangeLog b/plugins/itip-formatter/ChangeLog
index baff65ba48..b30fd70aaa 100644
--- a/plugins/itip-formatter/ChangeLog
+++ b/plugins/itip-formatter/ChangeLog
@@ -1,3 +1,17 @@
+2008-10-01 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #519491
+
+ * itip-view.c: (ensure_utf8), (itip_view_set_organizer),
+ (itip_view_set_organizer_sentby), (itip_view_set_attendee),
+ (itip_view_set_attendee_sentby), (itip_view_set_proxy),
+ (itip_view_set_delegator), (itip_view_set_summary),
+ (itip_view_set_location), (itip_view_set_status),
+ (itip_view_set_comment), (itip_view_set_description),
+ (itip_view_add_upper_info_item), (itip_view_add_lower_info_item):
+ Convert texts to valid UTF-8 texts before passing them to Gtk+
+ functions which requires that.
+
2008-09-24 Milan Crha <mcrha@redhat.com>
** Part of fix for bug #313225
diff --git a/plugins/itip-formatter/itip-view.c b/plugins/itip-formatter/itip-view.c
index e42b338e0f..1e5e41195c 100644
--- a/plugins/itip-formatter/itip-view.c
+++ b/plugins/itip-formatter/itip-view.c
@@ -1194,6 +1194,24 @@ itip_view_get_item_type (ItipView *view)
return priv->type;
}
+/* ensures the returned text will be valid UTF-8 text, thus gtk functions expecting
+ only valid UTF-8 texts will not crash. Returned pointer should be freed with g_free. */
+static gchar *
+ensure_utf8 (const char *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;
+}
void
itip_view_set_organizer (ItipView *view, const char *organizer)
@@ -1208,7 +1226,7 @@ itip_view_set_organizer (ItipView *view, const char *organizer)
if (priv->organizer)
g_free (priv->organizer);
- priv->organizer = g_strdup (organizer);
+ priv->organizer = ensure_utf8 (organizer);
set_sender_text (view);
}
@@ -1239,7 +1257,7 @@ itip_view_set_organizer_sentby (ItipView *view, const char *sentby)
if (priv->organizer_sentby)
g_free (priv->organizer_sentby);
- priv->organizer_sentby = g_strdup (sentby);
+ priv->organizer_sentby = ensure_utf8 (sentby);
set_sender_text (view);
}
@@ -1270,7 +1288,7 @@ itip_view_set_attendee (ItipView *view, const char *attendee)
if (priv->attendee)
g_free (priv->attendee);
- priv->attendee = g_strdup (attendee);
+ priv->attendee = ensure_utf8 (attendee);
set_sender_text (view);
}
@@ -1301,7 +1319,7 @@ itip_view_set_attendee_sentby (ItipView *view, const char *sentby)
if (priv->attendee_sentby)
g_free (priv->attendee_sentby);
- priv->attendee_sentby = g_strdup (sentby);
+ priv->attendee_sentby = ensure_utf8 (sentby);
set_sender_text (view);
}
@@ -1332,7 +1350,7 @@ itip_view_set_proxy (ItipView *view, const char *proxy)
if (priv->proxy)
g_free (priv->proxy);
- priv->proxy = g_strdup (proxy);
+ priv->proxy = ensure_utf8 (proxy);
set_sender_text (view);
}
@@ -1363,7 +1381,7 @@ itip_view_set_delegator (ItipView *view, const char *delegator)
if (priv->delegator)
g_free (priv->delegator);
- priv->delegator = g_strdup (delegator);
+ priv->delegator = ensure_utf8 (delegator);
set_sender_text (view);
}
@@ -1394,7 +1412,7 @@ itip_view_set_summary (ItipView *view, const char *summary)
if (priv->summary)
g_free (priv->summary);
- priv->summary = summary ? g_strstrip (g_strdup (summary)) : NULL;
+ priv->summary = summary ? g_strstrip (ensure_utf8 (summary)) : NULL;
set_summary_text (view);
}
@@ -1425,7 +1443,7 @@ itip_view_set_location (ItipView *view, const char *location)
if (priv->location)
g_free (priv->location);
- priv->location = location ? g_strstrip (g_strdup (location)) : NULL;
+ priv->location = location ? g_strstrip (ensure_utf8 (location)) : NULL;
set_location_text (view);
}
@@ -1456,7 +1474,7 @@ itip_view_set_status (ItipView *view, const char *status)
if (priv->status)
g_free (priv->status);
- priv->status = status ? g_strstrip (g_strdup (status)) : NULL;
+ priv->status = status ? g_strstrip (ensure_utf8 (status)) : NULL;
set_status_text (view);
}
@@ -1487,7 +1505,7 @@ itip_view_set_comment (ItipView *view, const char *comment)
if (priv->comment)
g_free (priv->comment);
- priv->comment = comment ? g_strstrip (g_strdup (comment)) : NULL;
+ priv->comment = comment ? g_strstrip (ensure_utf8 (comment)) : NULL;
set_comment_text (view);
}
@@ -1519,7 +1537,7 @@ itip_view_set_description (ItipView *view, const char *description)
if (priv->description)
g_free (priv->description);
- priv->description = description ? g_strstrip (g_strdup (description)) : NULL;
+ priv->description = description ? g_strstrip (ensure_utf8 (description)) : NULL;
set_description_text (view);
}
@@ -1624,7 +1642,7 @@ itip_view_add_upper_info_item (ItipView *view, ItipViewInfoItemType type, const
item = g_new0 (ItipViewInfoItem, 1);
item->type = type;
- item->message = g_strdup (message);
+ item->message = ensure_utf8 (message);
item->id = priv->next_info_item_id++;
priv->upper_info_items = g_slist_append (priv->upper_info_items, item);
@@ -1719,7 +1737,7 @@ itip_view_add_lower_info_item (ItipView *view, ItipViewInfoItemType type, const
item = g_new0 (ItipViewInfoItem, 1);
item->type = type;
- item->message = g_strdup (message);
+ item->message = ensure_utf8 (message);
item->id = priv->next_info_item_id++;
priv->lower_info_items = g_slist_append (priv->lower_info_items, item);