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 ecc910a..7bcfceb 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 215889f..c06683d 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 cbba791..c0290d0 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 4eceae6..5ba4f29 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 cbba791..c0290d0 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>