From 71e73497ba07ae9a9d4ae52caed545ee99a5e571 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 16 Dec 2011 06:06:26 +0000 Subject: [PATCH] luci-0.10: merge r8104 --- libs/web/htdocs/luci-static/resources/cbi.js | 7 ++++--- libs/web/luasrc/cbi/datatypes.lua | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js index 8d32b669d..e932dac1d 100644 --- a/libs/web/htdocs/luci-static/resources/cbi.js +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -153,8 +153,9 @@ var cbi_validators = { 'hostname': function(v) { if (v.length <= 253) - return (v.match(/^[a-zA-Z0-9]+$/) != null || - v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) != null); + return (v.match(/^[a-zA-Z]+$/) != null || + (v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) && + v.match(/[^0-9.]/))); return false; }, @@ -191,7 +192,7 @@ var cbi_validators = { 'neg_network_ip4addr': function(v) { v = v.replace(/^\s*!/, ""); - return cbi_validators.uciname(v) || cbi_validators.ip4addr(v); + return cbi_validators.uciname(v) || cbi_validators.ip4addr(v); }, 'range': function(v, args) diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua index 9a3b73500..65a8eedeb 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) -- 2.25.1