From: Jo-Philipp Wich Date: Wed, 14 Dec 2011 15:03:35 +0000 (+0000) Subject: luci-0.10: merge r8091 X-Git-Tag: 0.10.0~6 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=41469346de810a222033ba2e0b0f691d9bb7967f;p=oweals%2Fluci.git luci-0.10: merge r8091 --- diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js index 5eee59c34..123e8e1ab 100644 --- a/libs/web/htdocs/luci-static/resources/cbi.js +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -151,8 +151,10 @@ var cbi_validators = { }, 'hostname': function(v) - { if ( v.length <= 253 ) - return (v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) != null); + { + 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 false; }, diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua index fc3048e37..3c768ab76 100644 --- a/libs/web/luasrc/cbi/datatypes.lua +++ b/libs/web/luasrc/cbi/datatypes.lua @@ -141,7 +141,10 @@ function macaddr(val) end function hostname(val) - if val and (#val < 254) and val.match(val, "^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") then + 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]$") + ) then return true end return false