diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2011-12-16 06:05:51 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2011-12-16 06:05:51 +0000 |
commit | 375a476d27afae5c978b48a555fe32c94e2cf854 (patch) | |
tree | 5e0ee2f0a3b491a6c16417f26faf3f94f31e8564 /libs/web/luasrc | |
parent | 3a0905f21cb1afe307402cb8ea1d89096f28c141 (diff) |
libs/web: rework hostname match to not allow arbritary sequences of numbers and dots
Diffstat (limited to 'libs/web/luasrc')
-rw-r--r-- | libs/web/luasrc/cbi/datatypes.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua index 9a3b735008..65a8eedeb1 100644 --- a/libs/web/luasrc/cbi/datatypes.lua +++ b/libs/web/luasrc/cbi/datatypes.lua @@ -142,8 +142,9 @@ end function hostname(val) if val and (#val < 254) and ( - val:match("^[a-zA-Z0-9]+$") or - val:match("^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") + val:match("^[a-zA-Z]+$") or + (val:match("^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") and + val:match("[^0-9%.]")) ) then return true end @@ -238,7 +239,7 @@ function neg_network_ip4addr(val) if type(v) == "string" then v = v:gsub("^%s*!", "") return (uciname(v) or ip4addr(v)) - end + end end function range(val, min, max) |