commit 9def813: [Minor] Explicitly convert things to strings

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Feb 24 09:56:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-02-24 09:48:43 +0000
URL: https://github.com/rspamd/rspamd/commit/9def8135c34d06a01839e1cfbbe970438c76ddce

[Minor] Explicitly convert things to strings
Issue: #3272

---
 src/plugins/lua/dmarc.lua | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index ea5407fc3..4a68026c2 100644
--- a/src/plugins/lua/dmarc.lua
+++ b/src/plugins/lua/dmarc.lua
@@ -127,8 +127,18 @@ end
 
 local xml_grammar = gen_xml_grammar()
 
-local function escape_xml(goo)
-  return xml_grammar:match(goo)
+local function escape_xml(input)
+  if type(input) == 'string' or type(input) == 'userdata' then
+    return xml_grammar:match(input)
+  else
+    input = tostring(input)
+
+    if input then
+      return xml_grammar:match(input)
+    end
+  end
+
+  return ''
 end
 
 -- Default port for redis upstreams


More information about the Commits mailing list