diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2010-11-20 18:35:44 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2010-11-20 18:35:44 +0000 |
commit | be385bfcc63a4e75698ea7b564b0c1f5e50ba4ed (patch) | |
tree | c32d14223cc5c29f3349a7cc661756c76bed020d /libs | |
parent | d79895c0c3d8ac11e34a59a60e11d304c01fb08f (diff) |
libs/web: better server side handling of DynList values
Diffstat (limited to 'libs')
-rw-r--r-- | libs/web/luasrc/cbi.lua | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/libs/web/luasrc/cbi.lua b/libs/web/luasrc/cbi.lua index 50b594b4c..0fc93b25c 100644 --- a/libs/web/luasrc/cbi.lua +++ b/libs/web/luasrc/cbi.lua @@ -1657,15 +1657,27 @@ function DynamicList.value(self, key, val) end function DynamicList.write(self, section, value) - if self.cast == "string" and type(value) == "table" then - value = table.concat(value, " ") - elseif self.cast == "table" and type(value) == "string" then - local x, t = { } - for x in value:gmatch("%S+") do - if #x > 0 then + local t = { } + + if type(value) == "table" then + local x + for _, x in ipairs(value) do + if x and #x > 0 then t[#t+1] = x end end + elseif self.cast == "table" then + local x + for x in util.imatch(value) do + t[#t+1] = x + end + else + t = { value } + end + + if self.cast == "string" then + value = table.concat(t, " ") + else value = t end |