web: Relax hostname validation for length
[project/luci.git] / libs / web / luasrc / cbi / datatypes.lua
index 67cb63d..58b54de 100644 (file)
@@ -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 < 254) and val.match(val, "^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") then
+               return true
        end
-
        return false
 end