Index: /branches/cname-collision/DNSDB.pm
===================================================================
--- /branches/cname-collision/DNSDB.pm	(revision 1037)
+++ /branches/cname-collision/DNSDB.pm	(revision 1038)
@@ -949,5 +949,5 @@
         unless ${$args{val}} =~ /^(?:\.|\*\.|rpz-passthru\.|rpz-drop\.|rpz-tcp-only\.)$/;
       # Append the RPZ name
-      my $pname = ($args{defrec} eq 'y' ? 'DOMAIN' : $self->domainName($args{id}));
+      my $pname = ($args{defrec} eq 'y' ? 'DOMAIN' : $zname);
       ${$args{host}} =~ s/\.*$/\.$pname/ if ${$args{host}} !~ /$pname$/i;
     } else {
@@ -5007,4 +5007,15 @@
   }
 
+  # Minor cleanup of invalid DNS labels
+##fixme: seems like map should be used here to be decently Perlish, but any time I stick
+# a s/// inside the block map only returns the match/replace count instead of whatever
+# the changed $_ is for some reason
+  my @hbits = split /\./, $$host;
+  foreach (@hbits) {
+    s/^-+//;
+    s/-+$//;
+  }
+  $$host = join '.', @hbits;
+
   # Set up database fields and bind parameters
   $fields .= "host,type,val,ttl,"._recparent($defrec,$revrec);
@@ -5198,4 +5209,15 @@
     $retcode = 'WARN';
   }
+
+  # Minor cleanup of invalid DNS labels
+##fixme: seems like map should be used here to be decently Perlish, but any time I stick
+# a s/// inside the block map only returns the match/replace count instead of whatever
+# the changed $_ is for some reason
+  my @hbits = split /\./, $$host;
+  foreach (@hbits) {
+    s/^-+//;
+    s/-+$//;
+  }
+  $$host = join '.', @hbits;
 
   # Set up database fields and bind parameters.  Note only the optional fields
@@ -7040,4 +7062,5 @@
       $$recflags{$ip}++;
       next if $hpat eq '%blank%';	# Allows blanking a subnet so no records are published.
+      next if $hpat =~ /^\%blank\%/;	# Safety net in case of oopses elsewhere
       my $rec = $hpat;	# start fresh with the template for each IP
 ##fixme:  there really isn't a good way to handle sub-/24 zones here.  This way at least
