Changeset 617


Ignore:
Timestamp:
04/24/14 14:48:16 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Move case-folding in addRec() and updateRec() to its own sub. Add calls
in addDomain() and addRDNS() to case-fold records after all the other
mangling is done, just before inserting the new live record.

Extends/updates change in r542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r616 r617  
    11181118  return ('OK','OK');
    11191119}
     1120
     1121# Subs not specific to a particular record type
     1122
     1123# Convert $$host and/or $$val to lowercase as appropriate.
     1124# Should only be called if $self->{lowercase} is true.
     1125# $rectype is also a reference for caller convenience
     1126sub _caseclean {
     1127  my ($rectype, $host, $val, $defrec, $revrec) = @_;
     1128
     1129  # Can't case-squash default records, due to DOMAIN, ZONE, and ADMINDOMAIN templating
     1130  return if $defrec eq 'y';
     1131
     1132  if ($typemap{$$rectype} eq 'TXT' || $typemap{$$rectype} eq 'SPF') {
     1133    # TXT records should preserve user entry in the string.
     1134    # SPF records are a duplicate of TXT with a new record type value (99)
     1135    $$host = lc($$host) if $revrec eq 'n';      # only lowercase $$host on live forward TXT;  preserve TXT content
     1136    $$val = lc($$val) if $revrec eq 'y';        # only lowercase $$val on live reverse TXT;  preserve TXT content
     1137  } else {
     1138    # Non-TXT, live records, are fully case-insensitive
     1139    $$host = lc($$host);
     1140    $$val = lc($$val);
     1141  } # $typemap{$$rectype} else
     1142
     1143} # _caseclean()
    11201144
    11211145
     
    19852009      $host =~ s/DOMAIN/$domain/g;
    19862010      $val =~ s/DOMAIN/$domain/g;
     2011      _caseclean(\$type, \$host, \$val, 'n', 'n') if $self->{lowercase};
    19872012      $sth_in->execute($host, $type, $val, $dist, $weight, $port, $ttl, $defloc);
    19882013      if ($typemap{$type} eq 'SOA') {
     
    22892314        }
    22902315      }
     2316
     2317      _caseclean(\$type, \$host, \$val, 'n', 'y') if $self->{lowercase};
    22912318
    22922319      $sth_in->execute($domid,$host,$type,$val,$ttl,$defloc);
     
    38843911  }
    38853912
    3886   if ($self->{lowercase}) {
    3887     if ($typemap{$$rectype} ne 'TXT') {
    3888       $$host = lc($$host);
    3889       $$val = lc($$val);
    3890     } else {
    3891       # TXT records should preserve user entry in the string.
    3892       if ($revrec eq 'n') {
    3893         $$host = lc($$host);
    3894       } else {
    3895         $$val = lc($$val);
    3896       }
    3897     }
    3898   }
     3913  _caseclean($rectype, $host, $val, $defrec, $revrec) if $self->{lowercase};
    38993914
    39003915  # prep for validation
     
    40454060  }
    40464061
    4047   if ($self->{lowercase}) {
    4048     if ($typemap{$$rectype} ne 'TXT') {
    4049       $$host = lc($$host);
    4050       $$val = lc($$val);
    4051     } else {
    4052       # TXT records should preserve user entry in the string.
    4053       if ($revrec eq 'n') {
    4054         $$host = lc($$host);
    4055       } else {
    4056         $$val = lc($$val);
    4057       }
    4058     }
    4059   }
     4062  _caseclean($rectype, $host, $val, $defrec, $revrec) if $self->{lowercase};
    40604063
    40614064  # prep for validation
Note: See TracChangeset for help on using the changeset viewer.