Subject: | Warnings and test failure with Perl 5.8 < 5.8.9 |
On Perl 5.8 (highest I have for testing is 5.8.8, it may not be an issue
with 5.8.9), I see lots of warnings, e.g.:
t/05-A.....................Use of uninitialized value in lc at
/usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl
line 123.
ok
t/05-AAAA..................Use of uninitialized value in lc at
/usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl
line 123.
ok
t/05-AFSDB.................Use of uninitialized value in lc at
/usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl
line 123.
ok
t/05-APL...................Use of uninitialized value in lc at
/usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl
line 123.
ok
t/05-CERT..................Use of uninitialized value in lc at
/usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl
line 123.
ok
t/05-CNAME.................Use of uninitialized value in lc at
/usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl
line 123.
ok
This becomes more serious in t/07-zonefile.t, because
Net::DNS::ZoneFile->read is set up to die on warnings:
t/07-zonefile..............Use of uninitialized value in lc at
/usr/lib/perl5/5.8.8/utf8_heavy.pl line 123, <GEN5> line 1.
zone3.txt, line 1
at t/07-zonefile.t line 73
# Looks like you planned 46 tests but only ran 10.
# Looks like your test died just after 10.
dubious
Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 11-46
Failed 36/46 tests, 21.74% okay
I was able to work around this issue using the attached hack, which
didn't break builds on more modern perls that I tried, but it's an ugly
hack and I'd hope there was a cleaner solution, but my perl-fu isn't
strong enough for me to be able to think of one.
Subject: | Net-DNS-0.69-warnings.patch |
Perl 5.8 is prone to spewing warnings when operating on UTF strings,
such as:
t/05-A.....................Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
ok
t/05-AAAA..................Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
ok
t/05-AFSDB.................Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
ok
t/05-APL...................Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
ok
t/05-CERT..................Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
ok
t/05-CNAME.................Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123.
ok
This becomes more serious in t/07-zonefile.t, because Net::DNS::ZoneFile->read
is set up to die on warnings:
t/07-zonefile..............Use of uninitialized value in lc at /usr/lib/perl5/5.8.8/utf8_heavy.pl line 123, <GEN5> line 1.
zone3.txt, line 1
at t/07-zonefile.t line 73
# Looks like you planned 46 tests but only ran 10.
# Looks like your test died just after 10.
dubious
Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 11-46
Failed 36/46 tests, 21.74% okay
This horrible hack stops the warnings. Hopefully there's a cleaner way to do it!
--- lib/Net/DNS/ZoneFile.pm
+++ lib/Net/DNS/ZoneFile.pm
@@ -458,6 +458,7 @@ sub DESTROY { } ## Avoid tickling AUT
} elsif (/^\$TTL/) { # directive
my ( undef, $ttl ) = split;
die '$TTL incomplete' unless $ttl;
+ utf8::downgrade( $ttl, 1 ) or die 'non-ASCII TTL';
$self->{ttl} = Net::DNS::RR::ttl( {}, $ttl );
} elsif (/^\$GENERATE/) { # directive
my ( undef, $range, @template ) = split;
--- lib/Net/DNS/RR/SOA.pm
+++ lib/Net/DNS/RR/SOA.pm
@@ -59,7 +59,12 @@ sub parse_rdata { ## populate RR from
my $ttl = $self->{ttl};
$self->$_( @_ ? shift : () ) for qw(mname rname serial);
- $self->$_( @_ ? $self->ttl(shift) : () ) for qw(refresh retry expire minimum);
+ my @times = @_;
+ utf8::downgrade($times[0], 1) if $times[0];
+ utf8::downgrade($times[1], 1) if $times[1];
+ utf8::downgrade($times[2], 1) if $times[2];
+ utf8::downgrade($times[3], 1) if $times[3];
+ $self->$_( @times ? $self->ttl(shift @times) : () ) for qw(refresh retry expire minimum);
$self->{ttl} = $ttl;
}
--- lib/Net/DNS/RR/LOC.pm
+++ lib/Net/DNS/RR/LOC.pm
@@ -68,7 +68,12 @@ sub parse_rdata { ## populate RR from
}
$self->longitude(@long);
- $self->$_( @_ ? shift : () ) for qw(altitude size hp vp);
+ my @coords = @_;
+ utf8::downgrade($coords[0], 1) if $coords[0];
+ utf8::downgrade($coords[1], 1) if $coords[1];
+ utf8::downgrade($coords[2], 1) if $coords[2];
+ utf8::downgrade($coords[3], 1) if $coords[3];
+ $self->$_( @coords ? shift @coords : () ) for qw(altitude size hp vp);
}
--- lib/Net/DNS/RR.pm
+++ lib/Net/DNS/RR.pm
@@ -108,9 +108,19 @@ sub new_string {
my $name = shift @token; # name [ttl] [class] type ...
my $ttl = shift @token if @token && $token[0] =~ /^\d/;
- my $rrclass = shift @token if @token && $token[0] =~ /^($CLASS_REGEX)$/io;
+ my $rrclass;
+ if ( @token ) {
+ my $classtest = $token[0];
+ utf8::downgrade($classtest, 1);
+ if ( $classtest =~ /^($CLASS_REGEX)$/io ) {
+ shift @token;
+ $rrclass = $classtest;
+ }
+ }
$ttl = shift @token if @token && $token[0] =~ /^\d/; # name [class] [ttl] type ...
+ utf8::downgrade($ttl, 1);
my $rrtype = shift(@token) || croak 'unable to parse RR string';
+ utf8::downgrade($rrtype, 1) || croak 'non-ASCII RR type';
my $base = new Net::DNS::Question( $name, $rrtype, $rrclass );
my $self = $class->_subclass( $base, scalar @token ); # RR with defaults (if appropriate)
@@ -118,7 +128,9 @@ sub new_string {
return $self unless @token; # empty RR
- if ( $token[0] eq '\\#' ) {
+ my $tokentest = $token[0];
+ utf8::downgrade($tokentest, 1);
+ if ( $tokentest eq '\\#' ) {
shift @token; # RFC3597 hexadecimal format
my $count = shift(@token) || 0;
my $rdata = pack 'H*', join '', @token;