libs/web: allow one-character hostnames

This commit is contained in:
Jo-Philipp Wich 2011-12-14 15:01:54 +00:00
parent 3bccd25281
commit c5811d52d0
2 changed files with 8 additions and 3 deletions

View file

@ -151,8 +151,10 @@ var cbi_validators = {
}, },
'hostname': function(v) '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; return false;
}, },

View file

@ -141,7 +141,10 @@ function macaddr(val)
end end
function hostname(val) 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 return true
end end
return false return false