From c802c941cb5892ac43ee865594d3e06b60c00ace Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 6 Oct 2012 23:10:43 +0000 Subject: [PATCH] libs/web: relax validation for hostnames to allow names like _kerberos._udp.EXAMPLE.COM --- libs/web/htdocs/luci-static/resources/cbi.js | 4 ++-- libs/web/luasrc/cbi/datatypes.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js index b07215cbc..d8719c4b9 100644 --- a/libs/web/htdocs/luci-static/resources/cbi.js +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -148,8 +148,8 @@ var cbi_validators = { 'hostname': function() { if (this.length <= 253) - return (this.match(/^[a-zA-Z]+$/) != null || - (this.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) && + return (this.match(/^[a-zA-Z0-9]+$/) != null || + (this.match(/^[a-zA-Z0-9_][a-zA-Z0-9_\-.]*[a-zA-Z0-9]$/) && this.match(/[^0-9.]/))); return false; diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua index 48586194a..32530c465 100644 --- a/libs/web/luasrc/cbi/datatypes.lua +++ b/libs/web/luasrc/cbi/datatypes.lua @@ -179,8 +179,8 @@ end function hostname(val) if val and (#val < 254) and ( - val:match("^[a-zA-Z]+$") or - (val:match("^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") and + val:match("^[a-zA-Z_]+$") or + (val:match("^[a-zA-Z0-9_][a-zA-Z0-9_%-%.]*[a-zA-Z0-9]$") and val:match("[^0-9%.]")) ) then return true -- 2.11.0