luci-0.10: merge r8091
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 14 Dec 2011 15:03:35 +0000 (15:03 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 14 Dec 2011 15:03:35 +0000 (15:03 +0000)
libs/web/htdocs/luci-static/resources/cbi.js
libs/web/luasrc/cbi/datatypes.lua

index 5eee59c347fb3e2008b125dc6f83d7e4faa54487..123e8e1aba77f293107aff30acb2688c5759d929 100644 (file)
@@ -151,8 +151,10 @@ var cbi_validators = {
        },
 
        'hostname': function(v)
-       {       if ( v.length <= 253 )
-                       return (v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) != null);
+       {
+               if (v.length <= 253)
+                       return (v.match(/^[a-zA-Z0-9]+$/) != null ||
+                               v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) != null);
 
                return false;
        },
index fc3048e37e40524d4c292411824e99479d219b7d..3c768ab7623e03885eb8a3b735541d7b1a0d2e5e 100644 (file)
@@ -141,7 +141,10 @@ function macaddr(val)
 end
 
 function hostname(val)
-       if val and (#val < 254) and val.match(val, "^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") then
+       if val and (#val < 254) and (
+          val:match("^[a-zA-Z0-9]+$") or
+          val:match("^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$")
+       ) then
                return true
        end
        return false