libs/web: rework hostname match to not allow arbritary sequences of numbers and dots
This commit is contained in:
parent
3a0905f21c
commit
375a476d27
2 changed files with 8 additions and 6 deletions
|
@ -153,8 +153,9 @@ var cbi_validators = {
|
||||||
'hostname': function(v)
|
'hostname': function(v)
|
||||||
{
|
{
|
||||||
if (v.length <= 253)
|
if (v.length <= 253)
|
||||||
return (v.match(/^[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]$/) != null);
|
(v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) &&
|
||||||
|
v.match(/[^0-9.]/)));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
|
@ -142,8 +142,9 @@ end
|
||||||
|
|
||||||
function hostname(val)
|
function hostname(val)
|
||||||
if val and (#val < 254) and (
|
if val and (#val < 254) and (
|
||||||
val:match("^[a-zA-Z0-9]+$") or
|
val:match("^[a-zA-Z]+$") or
|
||||||
val:match("^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$")
|
(val:match("^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") and
|
||||||
|
val:match("[^0-9%.]"))
|
||||||
) then
|
) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue