telepathy-gabble: Update Wocky snapshot to validate stanza namespaces
Will Thompson
wjt at kemper.freedesktop.org
Wed Nov 14 10:20:35 PST 2012
Module: telepathy-gabble
Branch: master
Commit: 1d6c3044f13488e5457a31be631dec8e12068b6b
URL: http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=1d6c3044f13488e5457a31be631dec8e12068b6b
Author: Will Thompson <will.thompson at collabora.co.uk>
Date: Mon Nov 12 14:10:57 2012 +0000
Update Wocky snapshot to validate stanza namespaces
This breaks the console plugin, which checks if an entered stanza is of
a known type, but <message xmlns=''> is not the same as <message
xmlns='jabber:client'> so Wocky now says the former has type UNKNOWN.
The plugin already had some code to fix up empty namespaces, but it's
after the type check. For a better fix, I added API to give
non-streaming WockyXmppReaders a default namespace, and used it here.
In the course of fixing this, I found that telling the console to send
this:
<message>
<body>
hai
</body>
</message>
would send this:
<message xmlns='jabber:client'>
<body xmlns=''>
hai
</body>
</message>
which is wrong: the empty namespace was not being fixed up recursively.
This is fixed as a side-effect of the default-namespace property, but
this patch also adds a test.
https://bugs.freedesktop.org/show_bug.cgi?id=57016
---
lib/ext/wocky | 2 +-
plugins/console.c | 19 +++++++------------
tests/twisted/console.py | 14 ++++++++++----
tests/twisted/ns.py | 1 +
4 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/lib/ext/wocky b/lib/ext/wocky
index 0c9e226..31f33f4 160000
--- a/lib/ext/wocky
+++ b/lib/ext/wocky
@@ -1 +1 @@
-Subproject commit 0c9e226e165803d53a278b5fdbb3fb4c3f2330b0
+Subproject commit 31f33f4ba66bcdddda84b419cf4960073d071290
diff --git a/plugins/console.c b/plugins/console.c
index 8ec2894..fd49d0b 100644
--- a/plugins/console.c
+++ b/plugins/console.c
@@ -206,7 +206,8 @@ gabble_console_sidecar_init (GabbleConsoleSidecar *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GABBLE_TYPE_CONSOLE_SIDECAR,
GabbleConsoleSidecarPrivate);
- self->priv->reader = wocky_xmpp_reader_new_no_stream ();
+ self->priv->reader = wocky_xmpp_reader_new_no_stream_ns (
+ WOCKY_XMPP_NS_JABBER_CLIENT);
self->priv->writer = wocky_xmpp_writer_new_no_stream ();
}
@@ -517,7 +518,8 @@ validate_jid (const gchar **to,
/*
* @xml: doesn't actually have to be a top-level stanza. It can be the body of
- * an IQ or whatever.
+ * an IQ or whatever. If it has no namespace, it's assumed to be in
+ * jabber:client.
*/
static gboolean
parse_me_a_stanza (
@@ -621,7 +623,8 @@ stanza_looks_coherent (
if (t == WOCKY_STANZA_TYPE_UNKNOWN)
{
g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
- "I don't know what a <%s/> is", top_node->name);
+ "I don't know what a <%s xmlns='%s'/> is", top_node->name,
+ g_quark_to_string (top_node->ns));
return FALSE;
}
else if (st == WOCKY_STANZA_SUB_TYPE_UNKNOWN)
@@ -631,16 +634,8 @@ stanza_looks_coherent (
wocky_node_get_attribute (top_node, "type"));
return FALSE;
}
- else
- {
- if (top_node->ns == g_quark_from_static_string (""))
- {
- /* So... Wocky puts an empty string in as the namespace. Greaaat. */
- top_node->ns = g_quark_from_static_string (WOCKY_XMPP_NS_JABBER_CLIENT);
- }
- return TRUE;
- }
+ return TRUE;
}
static void
diff --git a/tests/twisted/console.py b/tests/twisted/console.py
index f6a6336..95c76a3 100644
--- a/tests/twisted/console.py
+++ b/tests/twisted/console.py
@@ -9,6 +9,7 @@ from servicetest import (
from gabbletest import exec_test, acknowledge_iq, elem, elem_iq
from config import PLUGINS_ENABLED
from twisted.words.xish import domish
+import ns
CONSOLE_PLUGIN_IFACE = "org.freedesktop.Telepathy.Gabble.Plugin.Console"
STACY = 'stacy at pilgrim.lit'
@@ -77,10 +78,15 @@ def test(q, bus, conn, stream):
</message>''' % { 'stacy': STACY })
e = q.expect('stream-message', to=STACY, message_type='headline')
- # Wocky fills in xmlns='' for us if we don't specify a namespace... great.
- # So this means <message/> gets sent as <message xmlns=''/> and the server
- # kicks us off.
- assertNotEquals('', e.stanza.uri)
+
+ # Make sure that Wocky has filled in the jabber:client namespace we
+ # carelessly omitted.
+ message = e.stanza
+ assertEquals('message', message.name)
+ assertEquals(ns.CLIENT, message.uri)
+ body = message.firstChildElement()
+ assertEquals('body', body.name)
+ assertEquals(ns.CLIENT, body.uri)
if __name__ == '__main__':
exec_test(test)
diff --git a/tests/twisted/ns.py b/tests/twisted/ns.py
index e1e6db9..458e4e1 100644
--- a/tests/twisted/ns.py
+++ b/tests/twisted/ns.py
@@ -2,6 +2,7 @@ AMP = "http://jabber.org/protocol/amp"
BYTESTREAMS = 'http://jabber.org/protocol/bytestreams'
CHAT_STATES = 'http://jabber.org/protocol/chatstates'
CAPS = "http://jabber.org/protocol/caps"
+CLIENT = "jabber:client"
DISCO_INFO = "http://jabber.org/protocol/disco#info"
DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
FEATURE_NEG = 'http://jabber.org/protocol/feature-neg'
More information about the telepathy-commits
mailing list