X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fxmppstream.lua;h=3d97acef1c87fde71187170435f8a3ac2c779707;hb=76e441c85feb7186cb9b1dcfb5b89fe66bb709f7;hp=7be63285dfdb48c8d219cab5190e930ffdaa6b9d;hpb=0979336ed04a158da127710b0cf574c885556668;p=prosody.git diff --git a/util/xmppstream.lua b/util/xmppstream.lua index 7be63285..3d97acef 100644 --- a/util/xmppstream.lua +++ b/util/xmppstream.lua @@ -196,6 +196,29 @@ local function new_sax_handlers(session, stream_callbacks, cb_handleprogress) end end + if stream_callbacks.track_namespaces then + local namespaces = {} + function xml_handlers:StartNamespaceDecl(prefix, url) + if prefix ~= nil then + namespaces[prefix] = url + end + end + function xml_handlers:EndNamespaceDecl(prefix) + if prefix ~= nil then + namespaces[prefix] = nil + end + end + local old_startelement = xml_handlers.StartElement + function xml_handlers:StartElement(tagname, attr) + old_startelement(self, tagname, attr) + local n = {} + for prefix, url in pairs(namespaces) do + n[prefix] = url + end + stanza.namespaces = n + end + end + local function restricted_handler(parser) cb_error(session, "parse-error", "restricted-xml", "Restricted XML, see RFC 6120 section 11.1."); if not parser.stop or not parser:stop() then