aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2008-10-09 22:19:35 +0500
committerWaqas Hussain <waqas20@gmail.com>2008-10-09 22:19:35 +0500
commitcbabb9cdb401a65c4ad0bc7b4d9b2c4af4eeb032 (patch)
treee6ca5f0b28c615f9492ce0313f051cc64b84356a
parent5ec7a9c8b4d215817cb158d824be869ff2441dbc (diff)
downloadprosody-cbabb9cdb401a65c4ad0bc7b4d9b2c4af4eeb032.tar.gz
prosody-cbabb9cdb401a65c4ad0bc7b4d9b2c4af4eeb032.zip
Fixed: util.stanza.deserialize now handles nil stanzas
-rw-r--r--util/stanza.lua24
1 files changed, 13 insertions, 11 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index a4fd0f82..6bc70ab9 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -122,21 +122,23 @@ end
function deserialize(stanza)
-- Set metatable
- setmetatable(stanza, stanza_mt);
- for _, child in ipairs(stanza) do
- if type(child) == "table" then
- deserialize(child);
- end
- end
- if not stanza.tags then
- -- Rebuild tags
- local tags = {};
+ if stanza then
+ setmetatable(stanza, stanza_mt);
for _, child in ipairs(stanza) do
if type(child) == "table" then
- t_insert(tags, child);
+ deserialize(child);
+ end
+ end
+ if not stanza.tags then
+ -- Rebuild tags
+ local tags = {};
+ for _, child in ipairs(stanza) do
+ if type(child) == "table" then
+ t_insert(tags, child);
+ end
end
+ stanza.tags = tags;
end
- stanza.tags = tags;
end
return stanza;