Changeset 542


Ignore:
Timestamp:
12/10/13 15:16:45 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Add config knob and supporting code to forcibly case-fold domain names
and hostnames. Defaults to off.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r541 r542  
    209209                max_fcgi_requests => 100,       # reasonable default?
    210210                force_refresh   => 1,
     211                lowercase       => 0,   # mangle as little as possible by default
    211212        );
    212213
     
    238239
    239240  # Several settings are booleans.  Handle multiple possible ways of setting them.
    240   for my $boolopt ('log_failures', 'force_refresh') {
     241  for my $boolopt ('log_failures', 'force_refresh', 'lowercase') {
    241242    if ($self->{$boolopt} ne '1' && $self->{$boolopt} ne '0') {
    242243      # true/false, on/off, yes/no all valid.
     
    13351336      $cfg->{perpage}           = $1 if /^perpage\s*=\s*(\d+)/i;
    13361337      $cfg->{exportcache}       = $1 if m{^exportcache\s*=\s*([a-z0-9/_.-]+)}i;
     1338      $cfg->{lowercase}         = $1 if /^lowercase\s*=\s*([a-z01]+)/i;
    13371339# not supported in dns.cgi yet
    13381340#      $cfg->{templatedir}      = $1 if m{^templatedir\s*=\s*([a-z0-9/_.-]+)}i;
     
    18191821
    18201822  return ('FAIL',"Invalid domain status") if $state !~ /^\d+$/;
     1823
     1824  $domain = lc($domain) if $self->{lowercase};
    18211825
    18221826  return ('FAIL', "Invalid characters in domain") if $domain !~ /^[a-zA-Z0-9_.-]+$/;
     
    36913695  }
    36923696
     3697  if ($self->{lowercase}) {
     3698    if ($typemap{$$rectype} ne 'TXT') {
     3699      $$host = lc($$host);
     3700      $$val = lc($$val);
     3701    } else {
     3702      # TXT records should preserve user entry in the string.
     3703      if ($revrec eq 'n') {
     3704        $$host = lc($$host);
     3705      } else {
     3706        $$val = lc($$val);
     3707      }
     3708    }
     3709  }
     3710
    36933711  # prep for validation
    36943712  my $addr = NetAddr::IP->new($$val);
     
    38223840    $$val =~ s/^\s+//;
    38233841    $$val =~ s/\s+$//;
     3842  }
     3843
     3844  if ($self->{lowercase}) {
     3845    if ($typemap{$$rectype} ne 'TXT') {
     3846      $$host = lc($$host);
     3847      $$val = lc($$val);
     3848    } else {
     3849      # TXT records should preserve user entry in the string.
     3850      if ($revrec eq 'n') {
     3851        $$host = lc($$host);
     3852      } else {
     3853        $$val = lc($$val);
     3854      }
     3855    }
    38243856  }
    38253857
Note: See TracChangeset for help on using the changeset viewer.