Commit 67889ac9 authored by Rob Jonson's avatar Rob Jonson Committed by Rémi Denis-Courmont

Move character escaping from the model contents, to the output helpers.

This is more reliable for ensuring everythign is escaped.
This allows different escaping for xml and json
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 7984b19c
......@@ -40,17 +40,17 @@ print('<root>\n')
for i,e in ipairs(browseTable.element._array) do
print('<element ')
print('\n<element ')
for k,v in pairs(e) do
print(" "..k.."='"..v.."'")
print(" "..httprequests.xmlString(k).."='"..httprequests.xmlString(v).."'")
end
print('/>')
end
print('</root>')
print('\n</root>')
?>
......@@ -37,7 +37,7 @@ local printleaf = function(item)
for k,v in pairs(item) do
if (k~="type") then
print(" "..k.."=\""..v.."\"")
print(" "..httprequests.xmlString(k).."=\""..httprequests.xmlString(v).."\"")
end
end
......@@ -56,7 +56,7 @@ local printnode = function(item)
elseif (k=="children") then
children=v._array
else
print(" "..k.."=\""..v.."\"")
print(" "..httprequests.xmlString(k).."=\""..httprequests.xmlString(v).."\"")
end
end
......
......@@ -49,7 +49,7 @@ local item = vlc.input.item()
if item then
local metas = item:metas()
for k,v in pairs(metas) do
print("<info name='"..vlc.strings.convert_xml_special_chars(k).."'>"..vlc.strings.convert_xml_special_chars(v).."</info>")
print("<info name='"..httprequests.xmlString(k).."'>"..httprequests.xmlString(v).."</info>")
end
end
?>
......@@ -58,9 +58,9 @@ local item = vlc.input.item()
if item then
local info = item:info()
for k, v in pairs(info) do
print("<category name='"..vlc.strings.convert_xml_special_chars(k).."'>")
print("<category name='"..httprequests.xmlString(k).."'>")
for k2, v2 in pairs(v) do
print("<info name='"..vlc.strings.convert_xml_special_chars(k2).."'>"..vlc.strings.convert_xml_special_chars(v2).."</info>")
print("<info name='"..httprequests.xmlString(k2).."'>"..httprequests.xmlString(v2).."</info>")
end
print("</category>")
end
......@@ -73,7 +73,7 @@ local item = vlc.input.item()
local stats = item:stats()
for k,v in pairs(stats) do
local tag = string.gsub(k,"_","")
print("<"..tag..">"..tostring(v).."</"..tag..">\n")
print("<"..httprequests.xmlString(tag)..">"..httprequests.xmlString(v).."</"..httprequests.xmlString(tag)..">\n")
end
end
?>
......
......@@ -187,7 +187,7 @@ end
--utilities for formatting output
local function xmlString(s)
function xmlString(s)
if (type(s)=="string") then
return vlc.strings.convert_xml_special_chars(s)
else
......@@ -252,7 +252,7 @@ local printXmlKeyValue = function (k,v,indent)
end
if (k) then
print("</"..k..">")
print("</"..xmlString(k)..">")
end
end
......@@ -301,7 +301,7 @@ parseplaylist = function (item)
if (item.children) then
local result={}
local name = vlc.strings.convert_xml_special_chars(item.name or "")
local name = (item.name or "")
result["type"]="node"
result.id=tostring(item.id)
......@@ -321,7 +321,8 @@ parseplaylist = function (item)
return result
else
local result={}
local name, path = vlc.strings.convert_xml_special_chars(item.name or "", item.path or "")
local name, path = item.name or ""
local path = item.path or ""
local current_item = vlc.input.item()
-- Is the item the one currently played
......@@ -376,7 +377,7 @@ getbrowsetable = function ()
if f == ".." or not string.match(f,"^%.") then
local df = common.realpath(dir..f)
local s = vlc.net.stat(df)
local path, name = vlc.strings.convert_xml_special_chars( df, f )
local path, name = df, f
local element={}
for k,v in pairs(s) do
......@@ -485,10 +486,10 @@ local aout = vlc.object.aout()
local streamTable={}
for k2, v2 in pairs(v) do
local tag = string.gsub(k2," ","_")
streamTable[xmlString(tag)]=xmlString(v2)
streamTable[tag]=v2
end
s.information.category[xmlString(k)]=streamTable
s.information.category[k]=streamTable
end
s.stats={}
......@@ -496,7 +497,7 @@ local aout = vlc.object.aout()
local statsdata = item:stats()
for k,v in pairs(statsdata) do
local tag = string.gsub(k,"_","")
s.stats[tag]=xmlString(v)
s.stats[tag]=v
end
end
return s
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment