diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-02-11 16:09:48 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-02-11 16:09:48 +0000 |
commit | 0a8bd35cebf8ee3772e1f9acd5740aea8db65d25 (patch) | |
tree | cea57e7eb223c02655535190b79300290af4ce32 /util | |
parent | d74b1cd4e2580aa24eb3091cf528a9a07ca6fa57 (diff) | |
download | prosody-0a8bd35cebf8ee3772e1f9acd5740aea8db65d25.tar.gz prosody-0a8bd35cebf8ee3772e1f9acd5740aea8db65d25.zip |
util.stanza: Temporary fix for serializing attributes with namespaces
Diffstat (limited to 'util')
-rw-r--r-- | util/stanza.lua | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/util/stanza.lua b/util/stanza.lua index 0b15ceed..1c1cab0e 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -12,6 +12,7 @@ local t_concat = table.concat; local t_remove = table.remove; local t_concat = table.concat; local s_format = string.format; +local s_match = string.match; local tostring = tostring; local setmetatable = setmetatable; local pairs = pairs; @@ -114,11 +115,22 @@ end local xml_escape = xml_escape; local function dostring(t, buf, self, xml_escape) + local nsid, ns, attrk = 0; t_insert(buf, "<"); t_insert(buf, t.name); for k, v in pairs(t.attr) do if type(k) == "string" then t_insert(buf, " "); - t_insert(buf, k); + ns, attrk = s_match(k, "^([^|]+)|(.+)$"); + if ns then + nsid = (nsid or -1) + 1; + t_insert(buf, "xmlns:ns"..nsid); + t_insert(buf, "='"); + t_insert(buf, (xml_escape(tostring(ns)))); + t_insert(buf, "' "); + t_insert(buf, "ns"..nsid..":"..attrk); + else + t_insert(buf, k); + end t_insert(buf, "='"); t_insert(buf, (xml_escape(tostring(v)))); t_insert(buf, "'"); |