X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=core%2Fxmlhandlers.lua;h=182da8940284e1e2f0f804fa7fa9fb08bc62f96a;hb=b4cbbfc80ba799c54dfeff37c44e2673a3322ace;hp=3d6ace12d0b5ce030bc0c258f4e68c74122db090;hpb=18b8bba2afbfd4dac8753a990334091283c62c03;p=prosody.git diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index 3d6ace12..182da894 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -1,6 +1,6 @@ -- Prosody IM --- Copyright (C) 2008-2009 Matthew Wild --- Copyright (C) 2008-2009 Waqas Hussain +-- Copyright (C) 2008-2010 Matthew Wild +-- Copyright (C) 2008-2010 Waqas Hussain -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. @@ -12,8 +12,6 @@ require "util.stanza" local st = stanza; local tostring = tostring; -local pairs = pairs; -local ipairs = ipairs; local t_insert = table.insert; local t_concat = table.concat; @@ -33,8 +31,6 @@ local ns_separator = "\1"; local ns_pattern = "^([^"..ns_separator.."]*)"..ns_separator.."?(.*)$"; function init_xmlhandlers(session, stream_callbacks) - local ns_stack = { "" }; - local curr_tag; local chardata = {}; local xml_handlers = {}; local log = session.log or default_log; @@ -72,8 +68,8 @@ function init_xmlhandlers(session, stream_callbacks) attr[i] = nil; local ns, nm = k:match(ns_pattern); if nm ~= "" then - ns = ns_prefixes[ns]; - if ns then + ns = ns_prefixes[ns]; + if ns then attr[ns..":"..nm] = attr[k]; attr[k] = nil; end @@ -97,7 +93,6 @@ function init_xmlhandlers(session, stream_callbacks) end stanza = st.stanza(name, attr); - curr_tag = stanza; else -- we are inside a stanza, so add a tag attr.xmlns = nil; if curr_ns ~= stream_default_ns then @@ -112,10 +107,6 @@ function init_xmlhandlers(session, stream_callbacks) end end function xml_handlers:EndElement(tagname) - local curr_ns,name = tagname:match(ns_pattern); - if name == "" then - curr_ns, name = "", curr_ns; - end if stanza then if #chardata > 0 then -- We have some character data in the buffer @@ -139,6 +130,10 @@ function init_xmlhandlers(session, stream_callbacks) cb_streamclosed(session); end else + local curr_ns,name = tagname:match(ns_pattern); + if name == "" then + curr_ns, name = "", curr_ns; + end cb_error(session, "parse-error", "unexpected-element-close", name); end stanza, chardata = nil, {};