util.stanza: Make xml_escape publicly accessible
authorMatthew Wild <mwild1@gmail.com>
Tue, 6 Oct 2009 17:05:31 +0000 (18:05 +0100)
committerMatthew Wild <mwild1@gmail.com>
Tue, 6 Oct 2009 17:05:31 +0000 (18:05 +0100)
util/stanza.lua

index 3bf7ea58a4bdcfa89b079da08f710f312bffe672..7b04c5086f3aeb8684ce3c2df9ece56c2e2a20d4 100644 (file)
@@ -118,10 +118,13 @@ function stanza_mt:childtags()
                                            
 end
 
-local xml_escape = (function()
+local xml_escape
+do
        local escape_table = { ["'"] = "&apos;", ["\""] = "&quot;", ["<"] = "&lt;", [">"] = "&gt;", ["&"] = "&amp;" };
-       return function(str) return (s_gsub(str, "['&<>\"]", escape_table)); end
-end)();
+       function xml_escape(str) return (s_gsub(str, "['&<>\"]", escape_table)); end
+       _M.xml_escape = xml_escape;
+end
+
 local function _dostring(t, buf, self, xml_escape)
        local nsid = 0;
        local name = t.name