[empathy: 2/3] empathy_tube_handler_build_bus_name: escape invalid char in the service name
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: svn-commits-list gnome org
- Subject: [empathy: 2/3] empathy_tube_handler_build_bus_name: escape invalid char in the service name
- Date: Tue, 21 Apr 2009 11:06:22 -0400 (EDT)
commit 3ba482ccc034647d8e4bde47f92e3a86720150a3
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Tue Apr 21 15:17:53 2009 +0100
empathy_tube_handler_build_bus_name: escape invalid char in the service name
---
libempathy/empathy-tube-handler.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/libempathy/empathy-tube-handler.c b/libempathy/empathy-tube-handler.c
index 4fb8217..18cda18 100644
--- a/libempathy/empathy-tube-handler.c
+++ b/libempathy/empathy-tube-handler.c
@@ -185,12 +185,31 @@ OUT:
return thandler;
}
+static gchar *
+sanitize_service_name (const gchar *str)
+{
+ guint i;
+ gchar *result;
+
+ g_assert (str != NULL);
+ result = g_strdup (str);
+
+ for (i = 0; result[i] != '\0'; i++)
+ {
+ if (!g_ascii_isalnum (result[i]))
+ result[i] = '_';
+ }
+
+ return result;
+}
+
gchar *
empathy_tube_handler_build_bus_name (TpTubeType type,
const gchar *service)
{
gchar *str = NULL;
const gchar *prefix = NULL;
+ gchar *service_escaped;
g_return_val_if_fail (type < NUM_TP_TUBE_TYPES, NULL);
g_return_val_if_fail (service != NULL, NULL);
@@ -202,7 +221,9 @@ empathy_tube_handler_build_bus_name (TpTubeType type,
else
g_return_val_if_reached (NULL);
- str = g_strconcat (prefix, service, NULL);
+ service_escaped = sanitize_service_name (service);
+ str = g_strconcat (prefix, service_escaped, NULL);
+ g_free (service_escaped);
return str;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]