From 9fa7e0e92ddae9ff68f50ad20bbdfc8a3c09135a Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Mon, 24 Mar 2008 21:50:48 +0000 Subject: * CBI: updates * UCI: fixed argument escaping --- src/ffluci/model/uci.lua | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/ffluci/model/uci.lua') diff --git a/src/ffluci/model/uci.lua b/src/ffluci/model/uci.lua index 5faffe5486..2d6702b577 100644 --- a/src/ffluci/model/uci.lua +++ b/src/ffluci/model/uci.lua @@ -79,6 +79,16 @@ function commit(...) end +-- Wrapper for "uci del" +function Session.del(self, config, section, option) + return self:_uci2("del " .. _path(config, section, option)) +end + +function del(...) + return default:del(...) +end + + -- Wrapper for "uci get" function Session.get(self, config, section, option) return self:_uci("get " .. _path(config, section, option)) @@ -173,12 +183,15 @@ function _path(...) -- Not using ipairs because it is not reliable in case of nil arguments arg.n = nil for k,v in pairs(arg) do - if k == 1 then - result = "'" .. v:gsub("['.]", "") .. "'" - elseif k < 4 then - result = result .. ".'" .. v:gsub("['.]", "") .. "'" - elseif k == 4 then - result = result .. "='" .. v:gsub("'", "") .. "'" + if v then + v = tostring(v) + if k == 1 then + result = "'" .. v:gsub("['.]", "") .. "'" + elseif k < 4 then + result = result .. ".'" .. v:gsub("['.]", "") .. "'" + elseif k == 4 then + result = result .. "='" .. v:gsub("'", "") .. "'" + end end end return result -- cgit v1.2.3