diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2012-11-12 14:10:57 +0000 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2012-11-14 18:17:34 +0000 |
commit | 1d6c3044f13488e5457a31be631dec8e12068b6b (patch) | |
tree | 618b9ffb7a8506a42cbc79b5dbaecf1a20ecb274 /plugins | |
parent | b09e286aa47dfafcc0809cee0e4fe97fd87f95c8 (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
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/console.c | 19 |
1 files changed, 7 insertions, 12 deletions
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 |