libs/web: relax validation for hostnames to allow names like _kerberos._udp.EXAMPLE.COM
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 6 Oct 2012 23:10:43 +0000 (23:10 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 6 Oct 2012 23:10:43 +0000 (23:10 +0000)
libs/web/htdocs/luci-static/resources/cbi.js
libs/web/luasrc/cbi/datatypes.lua

index b07215cbc4728995d00c261386b0caa56ad49a1b..d8719c4b91fbc44e16a4b8aa5f47f635c4547eed 100644 (file)
@@ -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;
index 48586194a6e1a1a424febb22274604abe9c2e53a..32530c465ad9f1816db3fdba1b880b2dca27047a 100644 (file)
@@ -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