mod_bosh: Only pass stanza to core_process_stanza if it wasn't dropped by filters
[prosody.git] / util / multitable.lua
index 299eecb13f73b15b1ab25881bd72a798239b6f03..dbf34d28ff33e4ba8c453270f2b751eeda128066 100644 (file)
@@ -144,18 +144,19 @@ function iter(self, ...)
                        keys[depth] = key;
                end
                local value = stack[depth][key];
-               if depth == maxdepth then -- Result
-                       local result = {}; -- Collect keys forming path to result
-                       for i = 1, depth do
-                               result[i] = keys[i];
+               if query[depth] == nil or key == query[depth] then
+                       if depth == maxdepth then -- Result
+                               local result = {}; -- Collect keys forming path to result
+                               for i = 1, depth do
+                                       result[i] = keys[i];
+                               end
+                               result[depth+1] = value;
+                               return unpack(result, 1, depth+1);
+                       elseif type(value) == "table" then
+                               t_insert(stack, value); -- Descend
                        end
-                       return unpack(result, 1, depth);
-               else
-                       if (query[depth] == nil or key == query[depth]) and type(value) == "table" then -- Descend
-                               t_insert(stack, value);
-                       end
-                       return it(self);
                end
+               return it(self);
        end;
        return it, self;
 end