X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=core%2Fxmlhandlers.lua;h=82c2d0b8d02361e95350d1f7c662225baf9d9149;hb=4341e61cc1ca8384a0ca18bad7f8f8f3f1c894b0;hp=573a9604ed7ca5c045d50ef4495d186d95ac66fb;hpb=e7c04fdd46bc9bb27abb73392bfba42326123968;p=prosody.git diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index 573a9604..82c2d0b8 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.4 +-- Prosody IM -- Copyright (C) 2008-2009 Matthew Wild -- Copyright (C) 2008-2009 Waqas Hussain -- @@ -29,7 +29,6 @@ local ns_prefixes = { function init_xmlhandlers(session, stream_callbacks) local ns_stack = { "" }; - local curr_ns, name = ""; local curr_tag; local chardata = {}; local xml_handlers = {}; @@ -50,8 +49,8 @@ function init_xmlhandlers(session, stream_callbacks) stanza:text(t_concat(chardata)); chardata = {}; end - local curr_ns,name = tagname:match("^(.-)|?([^%|]-)$"); - if not name then + local curr_ns,name = tagname:match("^([^\1]*)\1?(.*)$"); + if name == "" then curr_ns, name = "", curr_ns; end @@ -60,13 +59,14 @@ function init_xmlhandlers(session, stream_callbacks) end -- FIXME !!!!! - for i, k in ipairs(attr) do - local ns, nm = k:match("^([^|]+)|?([^|]-)$") - if ns and nm then + for i=1,#attr do + local k = attr[i]; + attr[i] = nil; + local ns, nm = k:match("^([^\1]*)\1?(.*)$"); + if nm ~= "" then ns = ns_prefixes[ns]; if ns then attr[ns..":"..nm] = attr[k]; - attr[i] = ns..":"..nm; attr[k] = nil; end end @@ -104,8 +104,8 @@ function init_xmlhandlers(session, stream_callbacks) end end function xml_handlers:EndElement(tagname) - curr_ns,name = tagname:match("^(.-)|?([^%|]-)$"); - if not name then + local curr_ns,name = tagname:match("^([^\1]*)\1?(.*)$"); + if name == "" then curr_ns, name = "", curr_ns; end if (not stanza) or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then @@ -113,12 +113,13 @@ function init_xmlhandlers(session, stream_callbacks) if cb_streamclosed then cb_streamclosed(session); end - return; elseif name == "error" then cb_error(session, "stream-error", stanza); else cb_error(session, "parse-error", "unexpected-element-close", name); end + stanza, chardata = nil, {}; + return; end if #chardata > 0 then -- We have some character data in the buffer