From 17500b46fbcf31e6afd564980934236121146c16 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 21 Mar 2018 22:04:20 +0000 Subject: util.stanza: Allow :text(nil) and :text("") as harmless nops --- util/stanza.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'util') 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 -- cgit v1.2.3