Blob Blame History Raw
diff --git a/dnssec-tools/tools/modules/ZoneFile-Fast/Fast.pm b/dnssec-tools/tools/modules/ZoneFile-Fast/Fast.pm
index cc9c6d3..3bc9a70 100644
--- a/dnssec-tools/tools/modules/ZoneFile-Fast/Fast.pm
+++ b/dnssec-tools/tools/modules/ZoneFile-Fast/Fast.pm
@@ -1335,7 +1335,20 @@ sub parse_tlsa
 sub parse_nsec3
   {
       #got more data
-      if ( /\G\s*((\w+\s+)*)\)\s*$/) {
+      if ( /\G\s*([A-Z0-9]{32})\s*(\))?/gc) {
+         my $nxthash = $1;
+	 my $binhash = MIME::Base32::decode(uc($nxthash));
+         $nsec3->{ 'hnxtname' } = $nxthash;
+         $nsec3->{ 'hnxtnamebin' } = $binhash;
+         $nsec3->{ 'hashlength' } = length( $binhash );
+         if ( defined($2) && $2 eq ')' ) {	# Was RR terminated ?
+	    push @zone, $nsec3; 
+	    # we're done
+	    $parse = \&parse_line;
+            $nsec3 = undef;
+         }
+      } elsif ( /\G\s+$/gc ) {			# Empty line
+      } elsif ( /\G\s*((\w+\s+)*)\)\s*$/) {
          my $typelist = $1;
 	 $typelist = join(" ",sort split(/\s+/,$typelist));
          $nsec3->{ 'typelist' } = $typelist;
@@ -1345,13 +1358,6 @@ sub parse_nsec3
 	 # we're done
 	 $parse = \&parse_line;
          $nsec3 = undef;
-      } elsif ( /\G\s*([A-Z0-9]{32})\s*$/gc) {
-         my $nxthash = $1;
-	 my $binhash = MIME::Base32::decode(uc($nxthash));
-         $nsec3->{ 'hnxtname' } = $nxthash;
-         $nsec3->{ 'hnxtnamebin' } = $binhash;
-         $nsec3->{ 'hashlength' } = length( $binhash );
-      } elsif ( /\G\s+$/gc ) {			# Empty line
       } else {
          error( "bad NSEC3 continuation lines ($_)" );
       }