]> git.0d.be Git - empathy.git/commitdiff
be less restrictive regarding the Service format
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 13 Jan 2012 15:03:25 +0000 (16:03 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 13 Jan 2012 15:12:12 +0000 (16:12 +0100)
libempathy-gtk/empathy-irc-network-chooser.c

index 0f147d8874cef021461d2cd529b1d3dba01b1350..74c9685e867861a9085c9fbdb4d2b507fee255de 100644 (file)
@@ -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