From b980b235c35a6cd040d539da0f675d83d2356049 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 13 Jan 2012 16:03:25 +0100 Subject: [PATCH 1/1] be less restrictive regarding the Service format --- libempathy-gtk/empathy-irc-network-chooser.c | 28 ++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/libempathy-gtk/empathy-irc-network-chooser.c b/libempathy-gtk/empathy-irc-network-chooser.c index 0f147d88..74c9685e 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 -- 2.39.2