Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 81786
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: yath [...] yath.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] Preserve last owner on multiline RRs starting with blanks
Date: Fri, 7 Dec 2012 23:31:25 +0100
To: bug-Net-DNS [...] rt.cpan.org
From: Sebastian Schmidt <yath [...] yath.de>
Previously, in Net::DNS::ZoneFile::_getline leading spaces were dropped from the RR if it spanend mutliple lines. This caused the RR owner to be set to whatever the first word (class/resource type/ttl) is. This patch saves the leading spaces from the RR so Net::DNS::ZoneFile::read can correctly set the current owner to the last owner. Tests for this behaviour have been added as well. --- lib/Net/DNS/ZoneFile.pm | 11 ++++++----- t/07-zonefile.t | 26 +++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/Net/DNS/ZoneFile.pm b/lib/Net/DNS/ZoneFile.pm index 2f69917..889e11a 100644 --- a/lib/Net/DNS/ZoneFile.pm +++ b/lib/Net/DNS/ZoneFile.pm @@ -433,14 +433,15 @@ sub DESTROY { } ## Avoid tickling AUTOLOAD (in cleanup) next if /^\s*$/; # discard blank line next if /^\s*;/; # discard comment line - while (/\(/) { # concatenate multi-line RR - s/\\\\/\\092/g; # disguise escaped escape - s/\\"/\\034/g; # disguise escaped double quote - s/\\;/\\059/g; # disguise escaped semicolon + while (/\(/) { # concatenate multi-line RR + my ($blanks) = /^(\s*)/; # save blanks at start of line + s/\\\\/\\092/g; # disguise escaped escape + s/\\"/\\034/g; # disguise escaped double quote + s/\\;/\\059/g; # disguise escaped semicolon my @token = grep defined && length, split /("[^"]*")|;[^\n]*|([()])|\s+/; last unless grep $_ eq '(', @token; last if grep $_ eq ')', @token; - $_ = "@token " . <$fh>; + $_ = "$blanks@token " . <$fh>; } if (/^\$INCLUDE/) { # directive diff --git a/t/07-zonefile.t b/t/07-zonefile.t index 079eeb5..7d8c2db 100644 --- a/t/07-zonefile.t +++ b/t/07-zonefile.t @@ -3,7 +3,7 @@ use strict; use FileHandle; -use Test::More tests => 46; +use Test::More tests => 54; use constant UTF8 => eval { require Encode; # expect this to fail pre-5.8.0 @@ -204,6 +204,30 @@ EOF is( scalar(@$listref), 2, 'parse RR string' ); } +{ + my $zonefile = source <<EOF; +\$TTL 1234 +\$ORIGIN example. +hosta A 192.0.2.1 + TXT ( a foo + goes into + a bar ) +hostb 23 AAAA ::1 + 42 A 192.0.2.1 +666 MX 10 hosta +EOF + is( $zonefile->read->name, 'hosta.example', 'first owner is correct' ); + is( $zonefile->read->name, 'hosta.example', 'owner of multiline RR taken from last RR' ); + my $rr = $zonefile->read; # hostb 23 AAAA ::1 + is( $rr->name, 'hostb.example', 'owner changed after multiline RR' ); + is( $rr->ttl, 23, 'ttl changed after multiline RR' ); + $rr = $zonefile->read; + is ($rr->name, 'hostb.example', 'hostb owner still set for different ttl' ); + is ($rr->ttl, 42, 'ttl changed for hostb/A' ); + $rr = $zonefile->read; + is ($rr->name, '666.example', 'new RR owner correctly set'); + is ($rr->ttl, 1234, 'new RR ttl taken from $TTL' ); +} SKIP: { ## Non-ASCII zone content skip( 'Non-ASCII content - Unicode/UTF-8 not supported', 2 ) unless UTF8; -- 1.7.10.4
Download signature.asc
application/pgp-signature 190b

Message body not shown because it is not plain text.

A (slightly different) fix is committed and will be in the 0.71 release. Thanks for reporting! WIllem