From 485ccb5ac65dc8beccd511c9575c3f58ae52d047 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 4 Aug 2009 22:15:38 +0100 Subject: Escape markup in notifications and icon tooltip 7730ffd fixed this for the notifications that are produced by the chat window, but not for the ones produced by the status icon. Why these are separate code paths eludes me. --- src/empathy-status-icon.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/empathy-status-icon.c') diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c index f6c63c537..1f6a32c95 100644 --- a/src/empathy-status-icon.c +++ b/src/empathy-status-icon.c @@ -23,6 +23,8 @@ #include +#include + #include #include @@ -136,16 +138,18 @@ status_icon_update_notification (EmpathyStatusIcon *icon) } if (priv->event) { + gchar *message_esc = g_markup_escape_text (priv->event->message, -1); + pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact, priv->event->icon_name); if (priv->notification) { notify_notification_update (priv->notification, - priv->event->header, priv->event->message, + priv->event->header, message_esc, NULL); } else { priv->notification = notify_notification_new_with_status_icon - (priv->event->header, priv->event->message, NULL, priv->icon); + (priv->event->header, message_esc, NULL, priv->icon); notify_notification_set_timeout (priv->notification, NOTIFY_EXPIRES_DEFAULT); @@ -160,6 +164,7 @@ status_icon_update_notification (EmpathyStatusIcon *icon) notify_notification_show (priv->notification, NULL); g_object_unref (pixbuf); + g_free (message_esc); } else { notification_close_helper (priv); } @@ -173,12 +178,12 @@ status_icon_update_tooltip (EmpathyStatusIcon *icon) if (priv->event) { if (priv->event->message != NULL) - tooltip = g_strdup_printf ("%s\n%s", - priv->event->header, - priv->event->message); + tooltip = g_markup_printf_escaped ("%s\n%s", + priv->event->header, + priv->event->message); else - tooltip = g_strdup_printf ("%s", - priv->event->header); + tooltip = g_markup_printf_escaped ("%s", + priv->event->header); gtk_status_icon_set_tooltip_markup (priv->icon, tooltip); } else { tooltip = g_strdup (empathy_idle_get_status (priv->idle)); -- cgit v1.2.3 From faef8889c4331af839cbec91691fe97ade60f9f7 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 4 Aug 2009 22:29:56 +0100 Subject: Don't try to free NULL pixbufs. It's all very well to ensure that we don't pass a NULL pixbuf to libnotify, but we shouldn't then try to g_object_unref () the pointer without checking it's not NULL. --- src/empathy-status-icon.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/empathy-status-icon.c') diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c index 1f6a32c95..79e59c5f5 100644 --- a/src/empathy-status-icon.c +++ b/src/empathy-status-icon.c @@ -140,9 +140,6 @@ status_icon_update_notification (EmpathyStatusIcon *icon) if (priv->event) { gchar *message_esc = g_markup_escape_text (priv->event->message, -1); - pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact, - priv->event->icon_name); - if (priv->notification) { notify_notification_update (priv->notification, priv->event->header, message_esc, @@ -155,15 +152,19 @@ status_icon_update_notification (EmpathyStatusIcon *icon) g_signal_connect (priv->notification, "closed", G_CALLBACK (status_icon_notification_closed_cb), icon); + } - } - /* if icon doesn't exist libnotify will crash */ - if (pixbuf != NULL) + pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact, + priv->event->icon_name); + + if (pixbuf != NULL) { notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf); + g_object_unref (pixbuf); + } + notify_notification_show (priv->notification, NULL); - g_object_unref (pixbuf); g_free (message_esc); } else { notification_close_helper (priv); -- cgit v1.2.3 From ec6cebc3342d4b8777f690df0f687fc00d3d7122 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 7 Aug 2009 12:21:08 +0100 Subject: status_icon_update_notification: don't crash if event->message is NULL g_markup_escape_text isn't NULL-safe so we should be sure that event->message is not NULL before calling it. --- src/empathy-status-icon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/empathy-status-icon.c') diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c index 79e59c5f5..bbb97f410 100644 --- a/src/empathy-status-icon.c +++ b/src/empathy-status-icon.c @@ -138,7 +138,10 @@ status_icon_update_notification (EmpathyStatusIcon *icon) } if (priv->event) { - gchar *message_esc = g_markup_escape_text (priv->event->message, -1); + gchar *message_esc = NULL; + + if (priv->event->message != NULL) + message_esc = g_markup_escape_text (priv->event->message, -1); if (priv->notification) { notify_notification_update (priv->notification, -- cgit v1.2.3