[notification-daemon] fix empty body when markup is not valid



commit 620c53fc9cec4ac4ed79754c71429be9db4a7a77
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Oct 12 20:18:36 2015 +0300

    fix empty body when markup is not valid
    
    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=801157

 src/nd-bubble.c           |   11 ++++++++++-
 src/nd-notification-box.c |   10 +++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/nd-bubble.c b/src/nd-bubble.c
index 6bc572d..2c276b1 100644
--- a/src/nd-bubble.c
+++ b/src/nd-bubble.c
@@ -623,7 +623,16 @@ set_notification_text (NdBubble   *bubble,
 
         g_free (str);
         gtk_widget_show_all (GTK_WIDGET (bubble));
-        gtk_label_set_markup (GTK_LABEL (bubble->priv->body_label), body);
+
+        if (pango_parse_markup (body, -1, 0, NULL, NULL, NULL, NULL))
+                gtk_label_set_markup (GTK_LABEL (bubble->priv->body_label), body);
+        else {
+                gchar *tmp;
+
+                tmp = g_markup_escape_text (body, -1);
+                gtk_label_set_text (GTK_LABEL (bubble->priv->body_label), body);
+                g_free (tmp);
+        }
 
         if (body == NULL || *body == '\0') {
                 bubble->priv->have_body = FALSE;
diff --git a/src/nd-notification-box.c b/src/nd-notification-box.c
index 72fd2bc..8e94180 100644
--- a/src/nd-notification-box.c
+++ b/src/nd-notification-box.c
@@ -222,7 +222,15 @@ update_notification_box (NdNotificationBox *notification_box)
 
         /* body */
         body = nd_notification_get_body (notification_box->priv->notification);
-        gtk_label_set_markup (GTK_LABEL (notification_box->priv->body_label), body);
+        if (pango_parse_markup (body, -1, 0, NULL, NULL, NULL, NULL))
+                gtk_label_set_markup (GTK_LABEL (notification_box->priv->body_label), body);
+        else {
+                gchar *tmp;
+
+                tmp = g_markup_escape_text (body, -1);
+                gtk_label_set_text (GTK_LABEL (notification_box->priv->body_label), body);
+                g_free (tmp);
+        }
 
         if (body != NULL && *body != '\0') {
                 gtk_widget_set_size_request (notification_box->priv->body_label,


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