Преглед изворни кода

ffho-config-mode-*: improve validation
Make bandwidth limits unsigned; trim numbers, the validator accepts
trailing whitespace.
Ported from https://github.com/freifunk-gluon/gluon/commit/6a6eb6282f18397798edef35e1a7cc4f0f93a9cd

Karsten Böddeker пре 8 година
родитељ
комит
0e0b97ec31

+ 3 - 2
ffho/ffho-config-mode-geo-location/files/lib/gluon/config-mode/wizard/0400-geo-location.lua

@@ -29,6 +29,7 @@ function M.section(form)
   o.rmempty = false
   o.datatype = "float"
   o.description = i18n.translatef("e.g. %s", "10.689901")
+
 end
 
 function M.handle(data)
@@ -36,8 +37,8 @@ function M.handle(data)
 
   uci:set("gluon-node-info", sname, "share_location", data._location)
   if data._location and data._latitude ~= nil and data._longitude ~= nil then
-    uci:set("gluon-node-info", sname, "latitude", data._latitude)
-    uci:set("gluon-node-info", sname, "longitude", data._longitude)
+    uci:set("gluon-node-info", sname, "latitude", data._latitude:trim())
+    uci:set("gluon-node-info", sname, "longitude", data._longitude:trim())
   end
   uci:save("gluon-node-info")
   uci:commit("gluon-node-info")

+ 4 - 4
ffho/ffho-config-mode-mesh-vpn/files/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua

@@ -28,13 +28,13 @@ function M.section(form)
   o:depends("_limit_enabled", "1")
   o.value = uci:get("simple-tc", "mesh_vpn", "limit_ingress")
   o.rmempty = false
-  o.datatype = "integer"
+  o.datatype = "uinteger"
 
   o = s:option(cbi.Value, "_limit_egress", i18n.translate("Upstream (kbit/s)"))
   o:depends("_limit_enabled", "1")
   o.value = uci:get("simple-tc", "mesh_vpn", "limit_egress")
   o.rmempty = false
-  o.datatype = "integer"
+  o.datatype = "uinteger"
 end
 
 function M.handle(data)
@@ -49,11 +49,11 @@ function M.handle(data)
     uci:set("simple-tc", "mesh_vpn", "ifname", "mesh-vpn")
 
     if data._limit_ingress ~= nil then
-      uci:set("simple-tc", "mesh_vpn", "limit_ingress", data._limit_ingress)
+      uci:set("simple-tc", "mesh_vpn", "limit_ingress", data._limit_ingress:trim())
     end
 
     if data._limit_egress ~= nil then
-      uci:set("simple-tc", "mesh_vpn", "limit_egress", data._limit_egress)
+      uci:set("simple-tc", "mesh_vpn", "limit_egress", data._limit_egress:trim())
     end
 
     uci:commit("simple-tc")