Changeset 8091

Show
Ignore:
Timestamp:
12/14/11 16:01:54 (18 months ago)
Author:
jow
Message:

libs/web: allow one-character hostnames

Location:
luci/trunk/libs/web
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/web/htdocs/luci-static/resources/cbi.js

    r7530 r8091  
    152152 
    153153    'hostname': function(v) 
    154     {   if ( v.length <= 253 ) 
    155             return (v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) != null); 
     154    { 
     155        if (v.length <= 253) 
     156            return (v.match(/^[a-zA-Z0-9]+$/) != null || 
     157                    v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) != null); 
    156158 
    157159        return false; 
  • luci/trunk/libs/web/luasrc/cbi/datatypes.lua

    r7458 r8091  
    142142 
    143143function hostname(val) 
    144     if val and (#val < 254) and val.match(val, "^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") then 
     144    if val and (#val < 254) and ( 
     145       val:match("^[a-zA-Z0-9]+$") or 
     146       val:match("^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") 
     147    ) then 
    145148        return true 
    146149    end