libs/web: fix dynamic list handling
authorJo-Philipp Wich <jow@openwrt.org>
Fri, 3 Dec 2010 12:41:12 +0000 (12:41 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Fri, 3 Dec 2010 12:41:12 +0000 (12:41 +0000)
libs/web/luasrc/cbi.lua

index ce99580..6934be6 100644 (file)
@@ -1346,7 +1346,7 @@ function AbstractValue.cfgvalue(self, section)
                        return value[1]
                end
        elseif self.cast == "table" then
-               return luci.util.split(value, "%s+", nil, true)
+               return { value }
        end
 end
 
@@ -1660,11 +1660,6 @@ function DynamicList.write(self, section, value)
                                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
@@ -1699,12 +1694,16 @@ function DynamicList.formvalue(self, section)
        local value = AbstractValue.formvalue(self, section)
 
        if type(value) == "string" then
-               local x
-               local t = { }
-               for x in value:gmatch("%S+") do
-                       t[#t+1] = x
+               if self.cast == "string" then
+                       local x
+                       local t = { }
+                       for x in value:gmatch("%S+") do
+                               t[#t+1] = x
+                       end
+                       value = t
+               else
+                       value = { value }
                end
-               value = t
        end
 
        return value