Software /
code /
prosody
Diff
util/xmppstream.lua @ 3633:4069c37c54bc
util.xmppstream: Preserve the stream content namespace on descendents of elements which are in another namespace.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 20 Nov 2010 02:28:40 +0500 |
parent | 3540:bc139431830b |
child | 3638:6f58a3063c14 |
line wrap: on
line diff
--- a/util/xmppstream.lua Fri Nov 19 03:20:29 2010 +0500 +++ b/util/xmppstream.lua Sat Nov 20 02:28:40 2010 +0500 @@ -48,6 +48,7 @@ local stream_default_ns = stream_callbacks.default_ns; local chardata, stanza = {}; + local non_streamns_depth = 0; function xml_handlers:StartElement(tagname, attr) if stanza and #chardata > 0 then -- We have some character data in the buffer @@ -59,8 +60,9 @@ curr_ns, name = "", curr_ns; end - if curr_ns ~= stream_default_ns then + if curr_ns ~= stream_default_ns or non_streamns_depth > 0 then attr.xmlns = curr_ns; + non_streamns_depth = non_streamns_depth + 1; end -- FIXME !!!!! @@ -80,6 +82,7 @@ if not stanza then --if we are not currently inside a stanza if session.notopen then if tagname == stream_tag then + non_streamns_depth = 0; if cb_streamopened then cb_streamopened(session, attr); end @@ -104,6 +107,9 @@ end end function xml_handlers:EndElement(tagname) + if non_streamns_depth > 0 then + non_streamns_depth = non_streamns_depth - 1; + end if stanza then if #chardata > 0 then -- We have some character data in the buffer