aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2019-12-23 13:12:32 +1000
committeronefang2019-12-23 13:12:32 +1000
commita46e3d567963a4e287177e8f6a94ff8fed659906 (patch)
treec26d09ddfc76244cb65a684553704fd8b0284531
parentAuto refresh web report. (diff)
downloadapt-panopticon-a46e3d567963a4e287177e8f6a94ff8fed659906.zip
apt-panopticon-a46e3d567963a4e287177e8f6a94ff8fed659906.tar.gz
apt-panopticon-a46e3d567963a4e287177e8f6a94ff8fed659906.tar.bz2
apt-panopticon-a46e3d567963a4e287177e8f6a94ff8fed659906.tar.xz
Attempt to sanitize the .lua table output.
Should get tested more, but it's good enough for now.
Diffstat (limited to '')
-rw-r--r--apt-panopticommon.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua
index 99dbeaf..42da301 100644
--- a/apt-panopticommon.lua
+++ b/apt-panopticommon.lua
@@ -250,7 +250,22 @@ dumpTableSub = function (table, space)
250 if type(v) == "table" then 250 if type(v) == "table" then
251 r = r .. APT.dumpTable(v, space, k) 251 r = r .. APT.dumpTable(v, space, k)
252 elseif type(v) == "string" then 252 elseif type(v) == "string" then
253 r = r .. space .. "[" .. k .. "] = '" .. v .. "';\n" 253 local bq = '"'
254 local eq = '"'
255 if nil ~= v:match(bq) then
256 bq, eq = '"', '"'
257 if nil ~= v:match(bq) then
258 bq, eq = '[[', ']]'
259 mbq, meq = '%[%[', '%]%]'
260 while (nil ~= v:match(mbq)) or (nil ~= v:match(meq)) do
261 bq = '[' .. '=' .. bq:sub(2, -1)
262 eq = ']' .. '=' .. eq:sub(2, -1)
263 mbq = '%[' .. '=' .. bq:sub(3, -1)
264 meq = '%]' .. '=' .. eq:sub(3, -1)
265 end
266 end
267 end
268 r = r .. space .. "[" .. k .. "] = " .. bq .. v .. eq .. ";\n"
254 elseif type(v) == "function" then 269 elseif type(v) == "function" then
255 r = r .. space .. "[" .. k .. "] = function ();\n" 270 r = r .. space .. "[" .. k .. "] = function ();\n"
256 elseif type(v) == "userdata" then 271 elseif type(v) == "userdata" then