[telepathy-glib/master] Work around protocol-escaping bug in MC5
Will Thompson
will.thompson at collabora.co.uk
Mon Sep 28 07:39:32 PDT 2009
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
telepathy-glib/account.c | 32 ++++++++++++++++++++++++--------
tests/dbus/account.c | 10 ++++++++++
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index e7b23ae..9c02b15 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -1206,6 +1206,29 @@ tp_account_new (TpDBusDaemon *bus_daemon,
return self;
}
+static gchar *
+unescape_protocol (gchar *protocol)
+{
+ if (strstr (protocol, "_2d") != NULL)
+ {
+ /* Work around MC5 bug where it escapes with tp_escape_as_identifier
+ * rather than doing it properly. MC5 saves the object path in your
+ * config, so if you've ever used a buggy MC5, the path will be wrong
+ * forever.
+ */
+ gchar **chunks = g_strsplit (protocol, "_2d", 0);
+ gchar *new = g_strjoinv ("-", chunks);
+
+ g_strfreev (chunks);
+ g_free (protocol);
+ protocol = new;
+ }
+
+ g_strdelimit (protocol, "_", '-');
+
+ return protocol;
+}
+
static void
_tp_account_got_all_cb (TpProxy *proxy,
GHashTable *properties,
@@ -2564,14 +2587,7 @@ tp_account_parse_object_path (const gchar *object_path,
}
set_or_free (cm, segments[0]);
-
- /* XXX: work around MC5 bug where it escapes with tp_escape_as_identifier
- * rather than doing it properly. MC5 saves the object path in your config,
- * so if you've ever used a buggy MC5, the path will be wrong forever.
- */
- g_strdelimit (segments[1], "_", '-');
- set_or_free (protocol, segments[1]);
-
+ set_or_free (protocol, unescape_protocol (segments[1]));
set_or_free (account_id, segments[2]);
/* Not g_strfreev because we stole or freed the individual strings */
diff --git a/tests/dbus/account.c b/tests/dbus/account.c
index accc15f..335a614 100644
--- a/tests/dbus/account.c
+++ b/tests/dbus/account.c
@@ -150,6 +150,16 @@ main (int argc,
TP_ACCOUNT_OBJECT_PATH_BASE "salut/local_xmpp/badgers",
"salut", "local-xmpp", "badgers"),
test_parse_success);
+ g_test_add_data_func ("/account/parse/wrongly-escaped-protocol",
+ test_parse_data_new (
+ TP_ACCOUNT_OBJECT_PATH_BASE "salut/local_2dxmpp/badgers",
+ "salut", "local-xmpp", "badgers"),
+ test_parse_success);
+ g_test_add_data_func ("/account/parse/wrongly-escaped-corner-case",
+ test_parse_data_new (
+ TP_ACCOUNT_OBJECT_PATH_BASE "salut/local_2d/badgers",
+ "salut", "local-", "badgers"),
+ test_parse_success);
g_test_add_data_func ("/account/parse/underscored-account",
test_parse_data_new (
TP_ACCOUNT_OBJECT_PATH_BASE "haze/msn/_thisseemsunlikely",
--
1.5.6.5
More information about the telepathy-commits
mailing list