aboutsummaryrefslogtreecommitdiffstats
path: root/util/stanza.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-21 22:04:20 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-21 22:04:20 +0000
commit17500b46fbcf31e6afd564980934236121146c16 (patch)
treeb1d4d8f36ea491c794e1ac093b5fd56a6c034abf /util/stanza.lua
parentc7116e7ac8ba1e780cdca3f3a45c9ec621e3caba (diff)
downloadprosody-17500b46fbcf31e6afd564980934236121146c16.tar.gz
prosody-17500b46fbcf31e6afd564980934236121146c16.zip
util.stanza: Allow :text(nil) and :text("") as harmless nops
Diffstat (limited to 'util/stanza.lua')
-rw-r--r--util/stanza.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index d16fc947..4a0a9ce8 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -111,9 +111,11 @@ function stanza_mt:tag(name, attr, namespaces)
end
function stanza_mt:text(text)
- check_text(text, "text");
- local last_add = self.last_add;
- (last_add and last_add[#last_add] or self):add_direct_child(text);
+ if text ~= nil and text ~= "" then
+ check_text(text, "text");
+ local last_add = self.last_add;
+ (last_add and last_add[#last_add] or self):add_direct_child(text);
+ end
return self;
end