[empathy] empathy_adium_path_is_valid: check if the directory has the right format



commit 408c581426ea8df05cc2b1c1663aa8405334f2ac
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Jul 4 15:44:43 2012 +0200

    empathy_adium_path_is_valid: check if the directory has the right format
    
    The Adium spec explicitely says that the root directory of the theme should
    end with ".AdiumMessageStyle".
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679332

 libempathy-gtk/empathy-theme-adium.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c
index 5cd3065..634b4b2 100644
--- a/libempathy-gtk/empathy-theme-adium.c
+++ b/libempathy-gtk/empathy-theme-adium.c
@@ -1752,10 +1752,30 @@ empathy_adium_path_is_valid (const gchar *path)
 {
   gboolean ret;
   gchar *file;
+  gchar **tmp;
+  const gchar *dir;
 
   if (path[0] != '/')
     return FALSE;
 
+  /* The directory has to be *.AdiumMessageStyle per the Adium spec */
+  tmp = g_strsplit (path, "/", 0);
+  if (tmp == NULL)
+    {
+      g_free (tmp);
+      return FALSE;
+    }
+
+  dir = tmp[g_strv_length (tmp) - 1];
+
+  if (!g_str_has_suffix (dir, ".AdiumMessageStyle"))
+    {
+      g_free (tmp);
+      return FALSE;
+    }
+
+  g_free (tmp);
+
   /* The theme is not valid if there is no Info.plist */
   file = g_build_filename (path, "Contents", "Info.plist",
          NULL);



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