diff options
author | Kim Alvefur <zash@zash.se> | 2018-11-17 15:48:32 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-11-17 15:48:32 +0100 |
commit | 5a4eaa0af27be5d07436fda04b5b4e519990b2cd (patch) | |
tree | b7dd1f7b94bc4a621e3f8785701731acdf5aa017 /util | |
parent | 7852a9791676ab5d32d40b32abc710f3a7bbab17 (diff) | |
parent | 3d3e0fa0826c0d107a7b99d875190ba4421f668a (diff) | |
download | prosody-5a4eaa0af27be5d07436fda04b5b4e519990b2cd.tar.gz prosody-5a4eaa0af27be5d07436fda04b5b4e519990b2cd.zip |
Merge 0.11->trunk
Diffstat (limited to 'util')
-rw-r--r-- | util/stanza.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/util/stanza.lua b/util/stanza.lua index 85c89d43..8d199912 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -398,7 +398,7 @@ local function deserialize(stanza) return stanza; end -local function clone(stanza) +local function _clone(stanza) local attr, tags = {}, {}; for k,v in pairs(stanza.attr) do attr[k] = v; end local old_namespaces, namespaces = stanza.namespaces; @@ -410,7 +410,7 @@ local function clone(stanza) for i=1,#stanza do local child = stanza[i]; if child.name then - child = clone(child); + child = _clone(child); t_insert(tags, child); end t_insert(new, child); @@ -418,6 +418,13 @@ local function clone(stanza) return setmetatable(new, stanza_mt); end +local function clone(stanza) + if not is_stanza(stanza) then + error("bad argument to clone: expected stanza, got "..type(stanza)); + end + return _clone(stanza); +end + local function message(attr, body) if not body then return new_stanza("message", attr); |