[polari] room: Strip color codes from room topics



commit 5944eadd9ac4b3c3c955058a79e51fba0ced8e13
Author: Kunaal Jain <kunaalus gmail com>
Date:   Wed Feb 10 00:13:57 2016 +0530

    room: Strip color codes from room topics
    
    Topic can be set by user, and some IRC clients
    support color codes. We don't support color codes,
    so displaying escape sequences looks broken.
    We already strip color codes for status messages
    (bug 711081), do the same for room topics.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747415

 src/lib/polari-room.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/lib/polari-room.c b/src/lib/polari-room.c
index 71e73f2..2777205 100644
--- a/src/lib/polari-room.c
+++ b/src/lib/polari-room.c
@@ -365,14 +365,23 @@ update_subject (PolariRoom *room,
                 GHashTable *properties)
 {
   PolariRoomPrivate *priv = room->priv;
-  const char *subject;
+  const char *raw_subject;
+  char *subject = NULL;
 
-  subject = tp_asv_get_string (properties, "Subject");
-  if (subject == NULL || g_strcmp0 (priv->topic, subject) == 0)
+  raw_subject = tp_asv_get_string (properties, "Subject");
+
+  if (raw_subject == NULL)
     return;
 
+  subject = strip_color_codes (raw_subject);
+  if (g_strcmp0 (priv->topic, subject) == 0)
+    {
+      g_free (subject);
+      return;
+    }
+
   g_free (priv->topic);
-  priv->topic = *subject ? g_strdup (subject) : NULL;
+  priv->topic = subject;
 
   g_object_notify_by_pspec (G_OBJECT (room), props[PROP_TOPIC]);
 }


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