Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions runtime/lua/xml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,27 @@ local function composeNode(frag, node, lvl)
t_insert(frag, '<')
t_insert(frag, node.elem)
if node.attrib then
local attribKeys = { }
for key, val in pairs(node.attrib) do
if val then
if type(key) ~= "string" then
return "invalid xml tree (attribute name in <"..node.elem.."> is not a string)"
elseif type(val) ~= "string" then
return "invalid xml tree (value for attribute '"..key.."' in <"..node.elem.."> is not a string)"
end
t_insert(frag, ' ')
t_insert(frag, key)
t_insert(frag, '="')
t_insert(frag, encodeContent(val))
t_insert(frag, '"')
t_insert(attribKeys, key)
end
end
table.sort(attribKeys)
for _, key in ipairs(attribKeys) do
local val = node.attrib[key]
if type(val) ~= "string" then
return "invalid xml tree (value for attribute '"..key.."' in <"..node.elem.."> is not a string)"
end
t_insert(frag, ' ')
t_insert(frag, key)
t_insert(frag, '="')
t_insert(frag, encodeContent(val))
t_insert(frag, '"')
end
end
if not node[1] then
t_insert(frag, '/>\n')
Expand Down
Loading