tools/ejabberd2prosody: Don't throw an error if XML CDATA is null ([] in Erlang, instead of a string or being missing).
authorWaqas Hussain <waqas20@gmail.com>
Tue, 18 Feb 2014 16:03:13 -0500
changeset 6024 c352d97cf137
parent 6023 93b4058e3320
child 6025 583e5c1365fe
tools/ejabberd2prosody: Don't throw an error if XML CDATA is null ([] in Erlang, instead of a string or being missing).
tools/ejabberd2prosody.lua
--- a/tools/ejabberd2prosody.lua	Mon Feb 17 16:00:41 2014 -0500
+++ b/tools/ejabberd2prosody.lua	Tue Feb 18 16:03:13 2014 -0500
@@ -44,8 +44,10 @@
 		for _, a in ipairs(tuple[4]) do build_stanza(a, stanza); end
 		if up then stanza:up(); else return stanza end
 	elseif tuple[1] == "xmlcdata" then
-		assert(type(tuple[2]) == "string", "XML CDATA has unexpected type: "..type(tuple[2]));
-		stanza:text(tuple[2]);
+		if type(tuple[2]) ~= "table" then
+			assert(type(tuple[2]) == "string", "XML CDATA has unexpected type: "..type(tuple[2]));
+			stanza:text(tuple[2]);
+		end -- else it's [], i.e., the null value, used for the empty string
 	else
 		error("unknown element type: "..serialize(tuple));
 	end