diff options
Diffstat (limited to 'libs/web')
-rw-r--r-- | libs/web/htdocs/luci-static/resources/cbi.js | 4 | ||||
-rw-r--r-- | libs/web/luasrc/cbi/datatypes.lua | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js index 44a5b2aec..d12d050a8 100644 --- a/libs/web/htdocs/luci-static/resources/cbi.js +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -141,8 +141,8 @@ var cbi_validators = { }, 'hostname': function(v) - { - return (v.match(/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/) != null); + { if ( v.length <= 24 ) + return (v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) != null); }, 'wpakey': function(v) diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua index 67cb63daf..d1ac8f405 100644 --- a/libs/web/luasrc/cbi/datatypes.lua +++ b/libs/web/luasrc/cbi/datatypes.lua @@ -127,10 +127,9 @@ function macaddr(val) end function hostname(val) - if val and val:match("[a-zA-Z0-9_][a-zA-Z0-9_%-%.]*") then - return true -- XXX: ToDo: need better solution + if val and (#val < 25) and val.match(val, "^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") then + return true end - return false end |