Created
October 4, 2009 18:04
-
-
Save zeen/201524 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 93a94ec05ebe util/stanza.lua | |
--- a/util/stanza.lua Sun Oct 04 22:12:12 2009 +0500 | |
+++ b/util/stanza.lua Sun Oct 04 23:07:05 2009 +0500 | |
@@ -122,7 +122,7 @@ | |
local escape_table = { ["'"] = "'", ["\""] = """, ["<"] = "<", [">"] = ">", ["&"] = "&" }; | |
return function(str) return (s_gsub(str, "['&<>\"]", escape_table)); end | |
end)(); | |
-local function _dostring(t, buf, self, xml_escape) | |
+local function _dostring(t, buf, self, xml_escape, parentns) | |
local nsid = 0; | |
local name = t.name | |
t_insert(buf, "<"..name); | |
@@ -131,7 +131,7 @@ | |
local ns, attrk = s_match(k, "^([^|]+)|(.+)$"); | |
nsid = nsid + 1; | |
t_insert(buf, " xmlns:ns"..nsid.."='"..xml_escape(ns).."' ".."ns"..nsid..":"..attrk.."='"..xml_e | |
scape(v).."'"); | |
- else | |
+ elseif not(k == "xmlns" and v == parentns) then | |
t_insert(buf, " "..k.."='"..xml_escape(v).."'"); | |
end | |
end | |
@@ -143,7 +143,7 @@ | |
for n=1,len do | |
local child = t[n]; | |
if child.name then | |
- self(child, buf, self, xml_escape); | |
+ self(child, buf, self, xml_escape, t.attr.xmlns); | |
else | |
t_insert(buf, xml_escape(child)); | |
end | |
@@ -153,7 +153,7 @@ | |
end | |
function stanza_mt.__tostring(t) | |
local buf = {}; | |
- _dostring(t, buf, _dostring, xml_escape); | |
+ _dostring(t, buf, _dostring, xml_escape, "jabber:client"); | |
return t_concat(buf); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment