Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: corycartwright [...] sbcglobal.net
Cc:
AdminCc:

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



Subject: NAPTR zone file incorrectly parsed from single line. v.710
NAPTR zone file incorrectly parsed from single line. Here is my test: This is incorrect Parsing string 5.5.5.5 1200 IN NAPTR 100 100 "u" "E2U+X-ADDRESS" "!^(.*)$!data:,CN=East test;ST=CT;C=United States;uid=ast1;intrunk=dms500!" . into RR object $VAR1 = bless( { 'rdlength' => 0, 'ttl' => '1200', 'name' => '5.5.5.5', 'class' => 'IN', 'type' => 'NAPTR', 'rdata' => '' }, 'Net::DNS::RR::NAPTR' ); This is correct 5.5.5.5. 1200 IN NAPTR 100 100 "u" "E2U+X-ADDRESS" "!^(.*)$!data:,CN=East test;ST=CT;C=United States;uid=ast1;intrunk=dms500!" .
Subject: zoneparse.pl
#!/usr/bin/perl use warnings; use strict; use Net::DNS; use Data::Dumper; print "This is incorrect\n"; my $string = '5.5.5.5 1200 IN NAPTR 100 100 "u" "E2U+X-ADDRESS" "!^(.*)$!data:,CN=East test;ST=CT;C=United States;uid=ast1;intrunk=dms500!" .'; print "Parsing string \n $string \ninto RR object\n"; my $newrr1 = new Net::DNS::RR "$string"; print Dumper($newrr1); print "\n"; my $newrr = Net::DNS::RR->new(name=> '5.5.5.5', ttl=> 1200, class=> 'IN', type => 'NAPTR', order => '100', preference => '100', flags => 'u', service => 'E2U+X-ADDRESS', regexp => '!^(.*)$!data:,CN=East test;ST=CT;C=United States;uid=ast1;intrunk=dms500!', replacment => '.', rdlength => 0, rdata => '', ); print "\nThis is correct\n"; print $newrr->string;
On Wed Aug 26 15:12:11 2009, corycartwright wrote: Show quoted text
> NAPTR zone file incorrectly parsed from single line. > > Here is my test: > > This is incorrect > Parsing string > 5.5.5.5 1200 IN NAPTR 100 100 "u" "E2U+X-ADDRESS" > "!^(.*)$!data:,CN=East test;ST=CT;C=United > States;uid=ast1;intrunk=dms500!" . > into RR object > $VAR1 = bless( { > 'rdlength' => 0, > 'ttl' => '1200', > 'name' => '5.5.5.5', > 'class' => 'IN', > 'type' => 'NAPTR', > 'rdata' => '' > }, 'Net::DNS::RR::NAPTR' ); > > > This is correct > 5.5.5.5. 1200 IN NAPTR 100 100 "u" "E2U+X-ADDRESS" > "!^(.*)$!data:,CN=East test;ST=CT;C=United > States;uid=ast1;intrunk=dms500!" .
This also happen using print $newrr1->string; rather then Dump($newrr1) I get: This is incorrect Parsing string 5.5.5.5. 1200 IN NAPTR 100 100 "u" "E2U+X-ADDRESS" "!^(.*)$!data:,CN=East test;ST=CT;C=United States;uid=ast1;intrunk=dms500!" . into RR object 5.5.5.5. 1200 IN NAPTR ; no data
Nasty little bug that had to do with recognizing comments (starting with ";") in RRs. Fixed on the trunk. (Changes for this in: http://www.net-dns.org/svn/net-dns/trunk/lib/Net/DNS/RR.pm ) --Olaf --- lib/Net/DNS/RR.pm (revision 800) +++ lib/Net/DNS/RR.pm (working copy) @@ -316,12 +316,51 @@ build_regex() unless $RR_REGEX; # strip out comments + # Comments start with a semi collon and run till end of line. + # However if the semi colon is escaped or inside a character string then we should keep it + # see e.g. rt.cpan 49035 + my $loopdetection=length($rrstring); + my $cleanstring; + while ($rrstring) { + + if ($rrstring=~s/^([^\\;'"]*)//o){ # Anything not special in this context. + $cleanstring.=$1; + } + if ($rrstring=~s/^(\\.)//o){ # Escaped special character + $cleanstring.=$1; + } + + if ($rrstring=~s/^((['"]).*(?<!\\)\2)//o){ # Anything within a matching string block. (non escaped terminator) + $cleanstring.=$1; + + # Next: Anything within a non matched string upto + # the first encountered comment (but first we + # want to make sure we captured all the nested + # blocks hence elsif + }elsif ($rrstring=~s/^((['"]).*((?<!\\);)?)//o){ + $cleanstring.=$1; + } + + $rrstring=~s/^(;.*\n)//o; # comment till newline + $rrstring=~s/^(;.*$)//o; # comment till end of string + print STDERR "."; + + confess "Failed stripping:loop will not terminate. Please report this info: ". $cleanstring ."---". $rrstring."\n" + if ($loopdetection==length($rrstring)); + $loopdetection=length($rrstring); + + + } + + + + # Test for non escaped ";" by means of the look-behind assertion # (the backslash is escaped) - $rrstring =~ s/(?<!\\);.*//og; + #$rrstring =~ s/(?<!\\);.*//og; - ($rrstring =~ m/$RR_REGEX/xso) || - confess qq|qInternal Error: "$rrstring" did not match RR pat.\nPlease report this to the author!\n|; + ($cleanstring =~ m/$RR_REGEX/xso) || + confess qq|Internal Error: "$rrstring" did not match RR pat.\nPlease report this to the author!\n|; my $name = $1; my $ttl = $2 || 0;
Subject: Re: [Bulk] [rt.cpan.org #49035] NAPTR zone file incorrectly parsed from single line. v.710
Date: Fri, 02 Oct 2009 15:24:12 -0400
To: bug-Net-DNS [...] rt.cpan.org
From: Cory Cartwright <corycartwright [...] sbcglobal.net>
Thank you Olaf! On Fri, 2009-10-02 at 12:21 -0400, Olaf Kolkman via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=49035 > > > > > Nasty little bug that had to do with recognizing comments (starting with ";") in RRs. > > Fixed on the trunk. > > (Changes for this in: > http://www.net-dns.org/svn/net-dns/trunk/lib/Net/DNS/RR.pm > ) > > > > --Olaf > > > --- lib/Net/DNS/RR.pm (revision 800) > +++ lib/Net/DNS/RR.pm (working copy) > @@ -316,12 +316,51 @@ > build_regex() unless $RR_REGEX; > > # strip out comments > + # Comments start with a semi collon and run till end of line. > + # However if the semi colon is escaped or inside a character string then we should keep > it > + # see e.g. rt.cpan 49035 > + my $loopdetection=length($rrstring); > + my $cleanstring; > + while ($rrstring) { > + > + if ($rrstring=~s/^([^\\;'"]*)//o){ # Anything not special in this context. > + $cleanstring.=$1; > + } > + if ($rrstring=~s/^(\\.)//o){ # Escaped special character > + $cleanstring.=$1; > + } > + > + if ($rrstring=~s/^((['"]).*(?<!\\)\2)//o){ # Anything within a matching string block. > (non escaped terminator) > + $cleanstring.=$1; > + > + # Next: Anything within a non matched string upto > + # the first encountered comment (but first we > + # want to make sure we captured all the nested > + # blocks hence elsif > + }elsif ($rrstring=~s/^((['"]).*((?<!\\);)?)//o){ > + $cleanstring.=$1; > + } > + > + $rrstring=~s/^(;.*\n)//o; # comment till newline > + $rrstring=~s/^(;.*$)//o; # comment till end of string > + print STDERR "."; > + > + confess "Failed stripping:loop will not terminate. Please report this info: ". > $cleanstring ."---". $rrstring."\n" > + if ($loopdetection==length($rrstring)); > + $loopdetection=length($rrstring); > + > + > + } > + > + > + > + > # Test for non escaped ";" by means of the look-behind assertion > # (the backslash is escaped) > - $rrstring =~ s/(?<!\\);.*//og; > + #$rrstring =~ s/(?<!\\);.*//og; > > - ($rrstring =~ m/$RR_REGEX/xso) || > - confess qq|qInternal Error: "$rrstring" did not match RR pat.\nPlease report this to > the author!\n|; > + ($cleanstring =~ m/$RR_REGEX/xso) || > + confess qq|Internal Error: "$rrstring" did not match RR pat.\nPlease report this to > the author!\n|; > > my $name = $1; > my $ttl = $2 || 0; >