Index: /trunk/DNSDB.pm
===================================================================
--- /trunk/DNSDB.pm	(revision 416)
+++ /trunk/DNSDB.pm	(revision 417)
@@ -3457,4 +3457,13 @@
   $location  = '' if !$location;
 
+  # Spaces are evil.
+  $$host =~ s/^\s+//;
+  $$host =~ s/\s+$//;
+  if ($typemap{$$type} ne 'TXT') {
+    # Leading or trailng spaces could be legit in TXT records.
+    $$val =~ s/^\s+//;
+    $$val =~ s/\s+$//;
+  }
+
   # prep for validation
   my $addr = NetAddr::IP->new($$val);
@@ -3574,4 +3583,13 @@
   my $location = shift;	# may be empty/null/undef depending on caller
   $location  = '' if !$location;
+
+  # Spaces are evil.
+  $$host =~ s/^\s+//;
+  $$host =~ s/\s+$//;
+  if ($typemap{$$type} ne 'TXT') {
+    # Leading or trailng spaces could be legit in TXT records.
+    $$val =~ s/^\s+//;
+    $$val =~ s/\s+$//;
+  }
 
   # prep for validation
@@ -4582,4 +4600,13 @@
 	$ttl = '' if $ttl == '0';
 
+	# Spaces are evil.
+	$$host =~ s/^\s+//;
+	$$host =~ s/\s+$//;
+	if ($typemap{$$type} ne 'TXT') {
+	  # Leading or trailng spaces could be legit in TXT records.
+	  $$val =~ s/^\s+//;
+	  $$val =~ s/\s+$//;
+	}
+
 	_printrec_tiny($datafile, 'n', \%recflags,
 		$dom, $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp);
