[empathy] be less restrictive regarding the Service format



commit b980b235c35a6cd040d539da0f675d83d2356049
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Jan 13 16:03:25 2012 +0100

    be less restrictive regarding the Service format

 libempathy-gtk/empathy-irc-network-chooser.c |   28 +++++++++++++++----------
 1 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/libempathy-gtk/empathy-irc-network-chooser.c b/libempathy-gtk/empathy-irc-network-chooser.c
index 0f147d8..74c9685 100644
--- a/libempathy-gtk/empathy-irc-network-chooser.c
+++ b/libempathy-gtk/empathy-irc-network-chooser.c
@@ -121,29 +121,35 @@ unset_server_params (EmpathyIrcNetworkChooser *self)
 static gchar *
 dup_network_service (EmpathyIrcNetwork *network)
 {
-  /* Account.Service follows the same restriction as CM.Protocol
-   * http://telepathy.freedesktop.org/spec/Connection_Manager.html#Simple-Type:Protocol
-   */
-#define VALID G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS
-  gchar *service;
-  gchar *result = NULL;
+  /* Account.Service has to be a lower case alphanumeric string which may
+   * also contain '-' but not start with it. */
+#define VALID G_CSET_a_2_z G_CSET_DIGITS "-"
+  gchar *service, *tmp;
 
   service = g_strdup (empathy_irc_network_get_name (network));
   service = g_strstrip (service);
 
-  /* Service has to start with a letter */
-  if (!g_ascii_isalpha (service[0]))
+  if (tp_str_empty (service))
     {
       g_free (service);
       return NULL;
     }
 
+  tmp = service;
+  service = g_ascii_strdown (service, -1);
+  g_free (tmp);
+
   service = g_strcanon (service, VALID, '-');
 
-  result = g_ascii_strdown (service, -1);
-  g_free (service);
+  if (service[0] == '-')
+    {
+      tmp = service;
+      service = g_strdup (service + 1);
+
+      g_free (tmp);
+    }
 
-  return result;
+  return service;
 }
 
 static void



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