projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4e04e35
)
Add some more datatype checks, patch by Eugene C., #499
author
Manuel Munz
<freifunk@somakoma.de>
Sat, 10 Nov 2012 20:55:50 +0000
(20:55 +0000)
committer
Manuel Munz
<freifunk@somakoma.de>
Sat, 10 Nov 2012 20:55:50 +0000
(20:55 +0000)
applications/luci-ddns/luasrc/model/cbi/ddns/ddns.lua
patch
|
blob
|
history
applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpc.lua
patch
|
blob
|
history
applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua
patch
|
blob
|
history
applications/luci-qos/luasrc/model/cbi/qos/qos.lua
patch
|
blob
|
history
applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua
patch
|
blob
|
history
modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua
patch
|
blob
|
history
diff --git
a/applications/luci-ddns/luasrc/model/cbi/ddns/ddns.lua
b/applications/luci-ddns/luasrc/model/cbi/ddns/ddns.lua
index
42fb4a6
..
e477a24
100644
(file)
--- a/
applications/luci-ddns/luasrc/model/cbi/ddns/ddns.lua
+++ b/
applications/luci-ddns/luasrc/model/cbi/ddns/ddns.lua
@@
-112,14
+112,19
@@
else
end
end
-s:option(Value, "check_interval",
- translate("Check for changed IP every")).default = 10
+ci = s:option(Value, "check_interval", translate("Check for changed IP every"))
+ci.datatype = "and(uinteger,min(1))"
+ci.default = 10
+
unit = s:option(ListValue, "check_unit", translate("Check-time unit"))
unit.default = "minutes"
unit:value("minutes", translate("min"))
unit:value("hours", translate("h"))
unit = s:option(ListValue, "check_unit", translate("Check-time unit"))
unit.default = "minutes"
unit:value("minutes", translate("min"))
unit:value("hours", translate("h"))
-s:option(Value, "force_interval", translate("Force update every")).default = 72
+fi = s:option(Value, "force_interval", translate("Force update every"))
+fi.datatype = "and(uinteger,min(1))"
+fi.default = 72
+
unit = s:option(ListValue, "force_unit", translate("Force-time unit"))
unit.default = "hours"
unit:value("minutes", translate("min"))
unit = s:option(ListValue, "force_unit", translate("Force-time unit"))
unit.default = "hours"
unit:value("minutes", translate("min"))
diff --git
a/applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpc.lua
b/applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpc.lua
index
ab7f73e
..
5265359
100644
(file)
--- a/
applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpc.lua
+++ b/
applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpc.lua
@@
-20,14
+20,21
@@
s.addremove = false
s:option(DummyValue, "_time", translate("Current system time")).value = os.date("%c")
s:option(DummyValue, "_time", translate("Current system time")).value = os.date("%c")
-s:option(Value, "interval", translate("Update interval (in seconds)")).rmempty = true
-s:option(Value, "count", translate("Count of time measurements"), translate("empty = infinite")).rmempty = true
+interval = s:option(Value, "interval", translate("Update interval (in seconds)"))
+interval.datatype = "and(uinteger,min(1))"
+interval.rmempty = true
+count = s:option(Value, "count", translate("Count of time measurements"), translate("empty = infinite"))
+count.datatype = "and(uinteger,min(1))"
+count.rmempty = true
s2 = m:section(TypedSection, "ntpdrift", translate("Clock Adjustment"))
s2.anonymous = true
s2.addremove = false
s2 = m:section(TypedSection, "ntpdrift", translate("Clock Adjustment"))
s2.anonymous = true
s2.addremove = false
-s2:option(Value, "freq", translate("Offset frequency")).rmempty = true
+
+freq = s2:option(Value, "freq", translate("Offset frequency"))
+freq.datatype = "integer"
+freq.rmempty = true
s3 = m:section(TypedSection, "ntpserver", translate("Time Servers"))
s3.anonymous = true
s3 = m:section(TypedSection, "ntpserver", translate("Time Servers"))
s3.anonymous = true
@@
-35,6
+42,8
@@
s3.addremove = true
s3.template = "cbi/tblsection"
s3:option(Value, "hostname", translate("Hostname"))
s3.template = "cbi/tblsection"
s3:option(Value, "hostname", translate("Hostname"))
-s3:option(Value, "port", translate("Port")).rmempty = true
+port = s3:option(Value, "port", translate("Port"))
+port.datatype = "port"
+port.rmempty = true
return m
return m
diff --git
a/applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua
b/applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua
index
9b56337
..
2a6c415
100644
(file)
--- a/
applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua
+++ b/
applications/luci-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua
@@
-21,8
+21,9
@@
s.addremove = false
s:option(DummyValue, "_time", translate("Current system time")).value = os.date("%c")
s:option(DummyValue, "_time", translate("Current system time")).value = os.date("%c")
-s:option(Value, "interval", translate("Update interval (in seconds)")).rmempty = true
-
+interval = s:option(Value, "interval", translate("Update interval (in seconds)"))
+interval.datatype = "and(uinteger,min(1))"
+interval.rmempty = true
s3 = m:section(TypedSection, "ntpserver", translate("Time Server"))
s3.anonymous = true
s3 = m:section(TypedSection, "ntpserver", translate("Time Server"))
s3.anonymous = true
@@
-30,6
+31,8
@@
s3.addremove = true
s3.template = "cbi/tblsection"
s3:option(Value, "hostname", translate("Hostname"))
s3.template = "cbi/tblsection"
s3:option(Value, "hostname", translate("Hostname"))
-s3:option(Value, "port", translate("Port")).rmempty = true
+port = s3:option(Value, "port", translate("Port"))
+port.datatype = "port"
+port.rmempty = true
return m
return m
diff --git
a/applications/luci-qos/luasrc/model/cbi/qos/qos.lua
b/applications/luci-qos/luasrc/model/cbi/qos/qos.lua
index
98e9a25
..
1af3bdb
100644
(file)
--- a/
applications/luci-qos/luasrc/model/cbi/qos/qos.lua
+++ b/
applications/luci-qos/luasrc/model/cbi/qos/qos.lua
@@
-35,9
+35,11
@@
s:option(Flag, "overhead", translate("Calculate overhead"))
s:option(Flag, "halfduplex", translate("Half-duplex"))
s:option(Flag, "halfduplex", translate("Half-duplex"))
-s:option(Value, "download", translate("Download speed (kbit/s)"))
+dl = s:option(Value, "download", translate("Download speed (kbit/s)"))
+dl.datatype = "and(uinteger,min(1))"
-s:option(Value, "upload", translate("Upload speed (kbit/s)"))
+ul = s:option(Value, "upload", translate("Upload speed (kbit/s)"))
+ul.datatype = "and(uinteger,min(1))"
s = m:section(TypedSection, "classify", translate("Classification Rules"))
s.template = "cbi/tblsection"
s = m:section(TypedSection, "classify", translate("Classification Rules"))
s.template = "cbi/tblsection"
diff --git
a/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua
b/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua
index
9ffefec
..
0c5766f
100644
(file)
--- a/
applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua
+++ b/
applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua
@@
-21,8
+21,12
@@
m = Map("qos")
s = m:section(NamedSection, "wan", "interface", translate("Internet Connection"))
s:option(Flag, "enabled", translate("Quality of Service"))
s = m:section(NamedSection, "wan", "interface", translate("Internet Connection"))
s:option(Flag, "enabled", translate("Quality of Service"))
-s:option(Value, "download", translate("Downlink"), "kbit/s")
-s:option(Value, "upload", translate("Uplink"), "kbit/s")
+
+dl = s:option(Value, "download", translate("Downlink"), "kbit/s")
+dl.datatype = "and(uinteger,min(1))"
+
+ul = s:option(Value, "upload", translate("Uplink"), "kbit/s")
+ul.datatype = "and(uinteger,min(1))"
s = m:section(TypedSection, "classify")
s.template = "cbi/tblsection"
s = m:section(TypedSection, "classify")
s.template = "cbi/tblsection"
diff --git
a/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua
b/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua
index
b0de191
..
0fa2696
100644
(file)
--- a/
modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua
+++ b/
modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua
@@
-202,10
+202,12
@@
m.uci:foreach("network", "switch",
local vid = s:option(Value, has_vlan4k or "vlan", "VLAN ID", "<div id='portstatus-%s'></div>" % switch_name)
local vid = s:option(Value, has_vlan4k or "vlan", "VLAN ID", "<div id='portstatus-%s'></div>" % switch_name)
+ local mx_vid = has_vlan4k and 4094 or (num_vlans - 1)
vid.rmempty = false
vid.forcewrite = true
vid.vlan_used = { }
vid.rmempty = false
vid.forcewrite = true
vid.vlan_used = { }
+ vid.datatype = "and(uinteger,range("..min_vid..","..mx_vid.."))"
-- Validate user provided VLAN ID, make sure its within the bounds
-- allowed by the switch.
-- Validate user provided VLAN ID, make sure its within the bounds
-- allowed by the switch.