tools/ejabberd2prosody: Don't throw an error if XML CDATA is null ([] in Erlang,...
authorWaqas Hussain <waqas20@gmail.com>
Tue, 18 Feb 2014 21:03:13 +0000 (16:03 -0500)
committerWaqas Hussain <waqas20@gmail.com>
Tue, 18 Feb 2014 21:03:13 +0000 (16:03 -0500)
tools/ejabberd2prosody.lua

index be1504b270c8ac7b61de062431885b519c0348a5..d0675a653e988ee99489f4fd78e11e8e89d6137f 100755 (executable)
@@ -44,8 +44,10 @@ function build_stanza(tuple, stanza)
                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