aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-irc-network-chooser.c28
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 0f147d887..74c9685e8 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