Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: cvicente [...] cpan.org
Cc:
AdminCc:

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



Subject: HINFO data parsing not standards-compliant?
From RFC1033: HINFO (Host Info) <host> [<ttl>] [<class>] HINFO <hardware> <software> The HINFO record gives information about a particular host. The data is two strings separated by whitespace. The first string is a hardware description and the second is software. The hardware is usually a manufacturer name followed by a dash and model designation. The software string is usually the name of the operating system. Official HINFO types can be found in the latest Assigned Numbers RFC, the latest of which is RFC-1010. The Hardware type is called the Machine name and the Software type is called the System name. Some sample HINFO records: SRI-NIC.ARPA. HINFO DEC-2060 TOPS20 UCBARPA.Berkeley.EDU. HINFO VAX-11/780 UNIX -- From what I read, the RFC does not require that fields be enclosed in quotation marks (single or double). Trying to create a new DNS::RR::HINFO record from the example record in the RFC does not work, unless the fields are enclosed in quotes. The following code: #!/usr/bin/perl -w use Net::DNS::RR; my $rr = Net::DNS::RR->new("SRI-NIC.ARPA. HINFO DEC-2060 TOPS20"); print $rr->type, "\n"; print "cpu = ", $rr->cpu, "\n"; print "os = ", $rr->os, "\n"; Returns: # perl test-hinfo.pl type= HINFO *** *** WARNING!!! The program has attempted to call the method *** "cpu" for the following RR object: *** *** SRI-NIC.ARPA. 0 IN HINFO ; no data *** Thanks for looking into this. cv
Show quoted text
> From what I read, the RFC does not require that fields be enclosed in > quotation marks (single or double). > > Trying to create a new DNS::RR::HINFO record from the example record in > the RFC does not work, unless the fields are enclosed in quotes. >
Well it is a bit more delicate than that: RFC1035 section 3.3.2 describes the format: CPU A <character-string> which specifies the CPU type. OS A <character-string> which specifies the operating system type. Standard values for CPU and OS can be found in [RFC-1010]. HINFO records are used to acquire general information about a host. The main use is for protocols such as FTP that can use special procedures when talking between machines or operating systems of the same type. Then in section 5.1 the zonefile representation for character strings is provided: <character-string> is expressed in one or two ways: as a contiguous set of characters without interior spaces, or as a string beginning with a " and ending with a ". Inside a " delimited string any character can occur, except for a " itself, which must be quoted using \ (back slash). Anyway, I patched the RR by using some functions that are made for parsing TXT RRs and I think that most cornercases are covered. Note that the new method will returned undefined when there are not exactly two "<character string>s" Below is the patch... ready for the next release. Index: lib/Net/DNS/RR/HINFO.pm ========================================================= ========== --- lib/Net/DNS/RR/HINFO.pm (revision 633) +++ lib/Net/DNS/RR/HINFO.pm (working copy) @@ -7,8 +7,9 @@ eval { require bytes; } } use vars qw(@ISA $VERSION); +use Net::DNS::RR::TXT; -@ISA = qw(Net::DNS::RR); +@ISA = qw(Net::DNS::RR Net::DNS::RR::TXT); $VERSION = (qw$LastChangedRevision$)[1]; sub new { @@ -35,12 +36,21 @@ } sub new_from_string { - my ($class, $self, $string) = @_; + my ( $class, $self, $rdata_string ) = @_ ; + + bless $self, $class; + + $self->_build_char_str_list($rdata_string); + my @elements= $self->char_str_list(); + if (@elements==2){ + + + $self->{"cpu"} = $elements[0]; + $self->{"os"} = $elements[1]; + }else{ + return; + } - if ($string && $string =~ /^["'](.*?)["']\s+["'](.*?)["']$/) { - $self->{"cpu"} = $1; - $self->{"os"} = $2; - } return bless $self, $class; }