aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authormatthew <devnull@localhost>2008-08-24 14:52:02 +0000
committermatthew <devnull@localhost>2008-08-24 14:52:02 +0000
commitdfe21804fe9558ac19d2327d2cf4ed16267bc3fc (patch)
treefa5e1bff817fd4c02459b874eb69f602e4de97ca /util
parent86ea5e7911605e1ff7bb1366d8357449a9139897 (diff)
downloadprosody-dfe21804fe9558ac19d2327d2cf4ed16267bc3fc.tar.gz
prosody-dfe21804fe9558ac19d2327d2cf4ed16267bc3fc.zip
Presence unavailable on disconnect
Diffstat (limited to 'util')
-rw-r--r--util/stanza.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index b4deda39..35277e9c 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -6,7 +6,7 @@ local setmetatable = setmetatable;
local pairs = pairs;
local ipairs = ipairs;
local type = type;
-
+local s_gsub = string.gsub;
module "stanza"
stanza_mt = {};
@@ -78,10 +78,21 @@ function stanza_mt:childtags()
end
+do
+ local xml_entities = { ["'"] = "&apos;", ["\""] = "&quot;", ["<"] = "&lt;", [">"] = "&gt;", ["&"] = "&amp;" };
+ function xml_escape(s) return s_gsub(s, "['&<>\"]", xml_entities); end
+end
+
+local xml_escape = xml_escape;
+
function stanza_mt.__tostring(t)
local children_text = "";
for n, child in ipairs(t) do
- children_text = children_text .. tostring(child);
+ if type(child) == "string" then
+ children_text = children_text .. xml_escape(child);
+ else
+ children_text = children_text .. tostring(child);
+ end
end
local attr_string = "";