summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2011-02-12 11:09:13 +0000
committerManuel Munz <freifunk@somakoma.de>2011-02-12 11:09:13 +0000
commit408a58f6f6b0d419bc6b81eb93f32c701e19118a (patch)
tree1f719c3aa68b99dd3768dedb499bf827d8afcb8f /modules
parent2b72c2093fa76e94bc249cba52c9b5b8b207e06e (diff)
web: Improve hostname validation
Diffstat (limited to 'modules')
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_system/system.lua2
-rw-r--r--modules/freifunk/luasrc/model/cbi/freifunk/basics.lua10
2 files changed, 2 insertions, 10 deletions
diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua b/modules/admin-full/luasrc/model/cbi/admin_system/system.lua
index dcd2fb0181..a0b8844f3b 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_system/system.lua
@@ -75,7 +75,7 @@ s:taboption("general", DummyValue, "_uptime", translate("Uptime")).value =
luci.tools.webadmin.date_format(tonumber(uptime))
hn = s:taboption("general", Value, "hostname", translate("Hostname"))
-
+hn.datatype = "hostname"
function hn.write(self, section, value)
Value.write(self, section, value)
luci.sys.hostname(value)
diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua b/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua
index b404181dc8..31ab9bb679 100644
--- a/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua
+++ b/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua
@@ -38,15 +38,7 @@ b.anonymous = true
hn = b:option(Value, "hostname", translate("Hostname"))
hn.rmempty = false
-function hn.validate(self, value)
- if value == nil then
- return
- elseif (#value > 24) or string.match(value, "[^%w%.%-]") or string.match(value, "^[%-%.]") or string.match(value, "[%-%.]$") then
- return nil, translate("Hostname may contain up to 24 alphanumeric characters. Minus and period are also allowed, but not in the beginning or the end of the hostname.")
- else
- return value
- end
-end
+hn.datatype = "hostname"
loc = b:option(Value, "location", translate("Location"))
loc.rmempty = false