Added missing value escaping
authorSteven Barth <steven@midlink.org>
Fri, 15 Aug 2008 18:18:16 +0000 (18:18 +0000)
committerSteven Barth <steven@midlink.org>
Fri, 15 Aug 2008 18:18:16 +0000 (18:18 +0000)
Fixed a typo (wrong if-condition)
Added support for Table objects in CBI

libs/cbi/luasrc/cbi.lua
modules/admin-full/luasrc/controller/admin/uci.lua
modules/admin-full/luasrc/view/admin_status/iwscan.htm
modules/admin-mini/luasrc/controller/mini/uci.lua
modules/admin-mini/luasrc/view/mini/iwscan.htm

index ecc910a13976cde86c8287ca4a05ca1bf60ab55b..7bcfceb2ef4794ed1dfa2695be7da357db9155ba 100644 (file)
@@ -479,6 +479,30 @@ function SimpleSection.__init__(self, form, ...)
 end
 
 
+Table = class(AbstractSection)
+
+function Table.__init__(self, form, data, ...)
+       local datasource = {}
+       self.data = data
+       
+       function datasource.get(self, section, option)
+               return data[option]
+       end
+       
+       AbstractSection.__init__(self, datasource, nil, ...)
+end
+
+function Table.cfgsections(self)
+       local sections = {}
+       
+       for i, v in pairs(self.data) do
+               table.insert(sections, i)
+       end
+       
+       return sections
+end
+
+
 
 --[[
 NamedSection - A fixed configuration section defined by its name
@@ -707,7 +731,7 @@ function AbstractValue.parse(self, section)
        else                                                    -- Unset the UCI or error
                if self.rmempty or self.optional then
                        self:remove(section)
-               elseif self.track_missing and not fvalue or fvalue ~= cvalue then
+               elseif self.track_missing and (not fvalue or fvalue ~= cvalue) then
                        self.tag_missing[section] = true
                end
        end
@@ -726,10 +750,10 @@ function AbstractValue.render(self, s, scope)
                        if cond then
                                return string.format(
                                        ' %s="%s"', tostring(key),
-                                       tostring( val
+                                       luci.util.pcdata(tostring( val
                                         or scope[key]
                                         or (type(self[key]) ~= "function" and self[key])
-                                        or "" )
+                                        or "" ))
                                )
                        else
                                return ''
index 215889f85ff1af4146fa495dfc394622b986892e..c06683d7166a53a328f12aeabdd177c595388a1e 100644 (file)
@@ -34,7 +34,7 @@ function convert_changes(changes)
                                        val = ""
                                else
                                        str = ""
-                                       val = "="..v
+                                       val = "="..luci.util.pcdata(v)
                                end
                                str = r.."."..s
                                if o ~= ".type" then
index cbba791e65fe958a6e4c3c5958752b864e4febe0..c0290d086ba63d0861de2a7578d3d2f70bdbf9c9 100644 (file)
@@ -34,7 +34,7 @@ $Id$
 %>
 <tr>
 <td><%=iface%></td>
-<td><%=cell.ESSID%></td>
+<td><%=luci.util.pcdata(cell.ESSID)%></td>
 <td><%=cell.Address%></td>
 <td><%=cell.Mode%></td>
 <td><%=(cell.Channel or cell.Frequency or "")%></td>
index 4eceae6293360f98c7f100b3bf7de51472d2872b..5ba4f2949e20129f8b705959936549a90349262b 100644 (file)
@@ -34,7 +34,7 @@ function convert_changes(changes)
                                        val = ""
                                else
                                        str = ""
-                                       val = "="..v
+                                       val = "="..luci.util.pcdata(v)
                                end
                                str = r.."."..s
                                if o ~= ".type" then
index cbba791e65fe958a6e4c3c5958752b864e4febe0..c0290d086ba63d0861de2a7578d3d2f70bdbf9c9 100644 (file)
@@ -34,7 +34,7 @@ $Id$
 %>
 <tr>
 <td><%=iface%></td>
-<td><%=cell.ESSID%></td>
+<td><%=luci.util.pcdata(cell.ESSID)%></td>
 <td><%=cell.Address%></td>
 <td><%=cell.Mode%></td>
 <td><%=(cell.Channel or cell.Frequency or "")%></td>