summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2012-11-12 14:10:57 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2012-11-14 18:17:34 +0000
commit1d6c3044f13488e5457a31be631dec8e12068b6b (patch)
tree618b9ffb7a8506a42cbc79b5dbaecf1a20ecb274
parentb09e286aa47dfafcc0809cee0e4fe97fd87f95c8 (diff)
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
m---------lib/ext/wocky0
-rw-r--r--plugins/console.c19
-rw-r--r--tests/twisted/console.py14
-rw-r--r--tests/twisted/ns.py1
4 files changed, 18 insertions, 16 deletions
diff --git a/lib/ext/wocky b/lib/ext/wocky
-Subproject 0c9e226e165803d53a278b5fdbb3fb4c3f2330b
+Subproject 31f33f4ba66bcdddda84b419cf4960073d07129
diff --git a/plugins/console.c b/plugins/console.c
index 8ec2894ac..fd49d0bd8 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 f6a6336c9..95c76a30e 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@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 e1e6db977..458e4e156 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'