Hello everyone,

I've recently been using Net::DNS as part of a project at work, and have been blocked by this bug.

It appears that subroutine new_from_string is too naive when stripping comments, and fails to cope with semi-colons embedded within TXT data.

I'm proposing the following simple patch to resolve this, and would like the opinions of the brethren before I consider passing it on to the maintainer.

The patched code passes all the tests provided with the current (v0.48) Net::DNS distribution.

Thanks in advance for any comments.

--- Net-DNS-0.48/lib/Net/DNS/RR.pm 2004-08-12 06:48:00.000000000 ++0100 +++ SC-Net-DNS-0.48/lib/Net/DNS/RR.pm 2004-12-13 15:56:19.583003131 ++0000 @@ -250,9 +250,6 @@ build_regex() unless $RR_REGEX; - # strip out comments - $rrstring =~ s/;.*//g; - ($rrstring =~ m/$RR_REGEX/xso) || confess qq|qInternal Error: "$rrstring" did not match +RR pat.\nPlease report this to the author!\n|; @@ -265,8 +262,20 @@ my $rdata = $5 || ''; $rdata =~ s/\s+$// if $rdata; - $name =~ s/\.$// if $name; + # strip out comments + if($rrtype eq 'TXT') { + if(($rdata)=~m[;]) { + if(($rdata)=~m[^(".*")($|\s*;)]) { + $rdata = $1; + } else { + ($rdata)=~s/;.*//g; + } + } + } else { + ($rdata)=~s/;.*//g; + } + $name =~ s/\.$// if $name; # RFC3597 tweaks # This converts to known class and type if specified as TYPE## +#

In reply to Net::DNS::RR patch by slife

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.