From 408a58f6f6b0d419bc6b81eb93f32c701e19118a Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Sat, 12 Feb 2011 11:09:13 +0000 Subject: web: Improve hostname validation --- libs/web/luasrc/cbi/datatypes.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libs/web/luasrc/cbi') diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua index 67cb63daf0..d1ac8f405a 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 -- cgit v1.2.3