prosodyctl: Fix import of util.iterators
[prosody.git] / util / xmppstream.lua
index 018f238d1d3649b7c5028a234d01f7321844bf32..f1793b4f958540bad92bd1a77fa0b9ea128b223b 100644 (file)
@@ -20,20 +20,16 @@ local setmetatable = setmetatable;
 
 -- COMPAT: w/LuaExpat 1.1.0
 local lxp_supports_doctype = pcall(lxp.new, { StartDoctypeDecl = false });
-if not lxp_supports_doctype then
-       local default_log = require "util.logger".init("xmppstream");
-       default_log("warn", "The version of LuaExpat on your system leaves Prosody "
-               .."vulnerable to denial-of-service attacks. You should upgrade to "
-               .."LuaExpat 1.1.1 or higher as soon as possible. See "
-               .."http://prosody.im/doc/depends#luaexpat for more information.");
-end
 
 module "xmppstream"
 
 local new_parser = lxp.new;
 
-local ns_prefixes = {
-       ["http://www.w3.org/XML/1998/namespace"] = "xml";
+local xml_namespace = {
+       ["http://www.w3.org/XML/1998/namespace\1lang"] = "xml:lang";
+       ["http://www.w3.org/XML/1998/namespace\1space"] = "xml:space";
+       ["http://www.w3.org/XML/1998/namespace\1base"] = "xml:base";
+       ["http://www.w3.org/XML/1998/namespace\1id"] = "xml:id";
 };
 
 local xmlns_streams = "http://etherx.jabber.org/streams";
@@ -80,17 +76,13 @@ function new_sax_handlers(session, stream_callbacks)
                        non_streamns_depth = non_streamns_depth + 1;
                end
                
-               -- FIXME !!!!!
                for i=1,#attr do
                        local k = attr[i];
                        attr[i] = nil;
-                       local ns, nm = k:match(ns_pattern);
-                       if nm ~= "" then
-                               ns = ns_prefixes[ns];
-                               if ns then
-                                       attr[ns..":"..nm] = attr[k];
-                                       attr[k] = nil;
-                               end
+                       local xmlk = xml_namespace[k];
+                       if xmlk then
+                               attr[xmlk] = attr[k];
+                               attr[k] = nil;
                        end
                end
                
@@ -147,19 +139,9 @@ function new_sax_handlers(session, stream_callbacks)
                                stanza = t_remove(stack);
                        end
                else
-                       if tagname == stream_tag then
-                               if cb_streamclosed then
-                                       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);
+                       if cb_streamclosed then
+                               cb_streamclosed(session);
                        end
-                       stanza, chardata = nil, {};
-                       stack = {};
                end
        end