xmlhandlers: Fix tag pattern again for the default namespace
[prosody.git] / core / xmlhandlers.lua
index 67a0829d63acef05c1fdda4702de8842d7899a37..7e09921c333f1e6fc3f778be0203fae2c90ccaba 100644 (file)
@@ -57,7 +57,11 @@ function init_xmlhandlers(session, stream_callbacks)
                                stanza:text(t_concat(chardata));
                                chardata = {};
                        end
-                       local curr_ns,name = tagname:match("^(.+)|([^%|]+)$");
+                       local curr_ns,name = tagname:match("^(.-)|?([^%|]-)$");
+                       if not name then
+                               curr_ns, name = "", curr_ns;
+                       end
+
                        if curr_ns ~= stream_default_ns then
                                attr.xmlns = curr_ns;
                        end
@@ -109,7 +113,10 @@ function init_xmlhandlers(session, stream_callbacks)
                        end
                end
                function xml_handlers:EndElement(tagname)
-                       curr_ns,name = tagname:match("^(.+)|([^%|]+)$");
+                       curr_ns,name = tagname:match("^(.-)|?([^%|]-)$");
+                       if not 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 
                                if tagname == stream_tag then
                                        if cb_streamclosed then