Skip Menu |
 

This queue is for tickets about the HTML-ParseBrowser CPAN distribution.

Report information
The Basics
Id: 40100
Status: resolved
Priority: 0/
Queue: HTML-ParseBrowser

People
Owner: Nobody in particular
Requestors: rjk [...] tamias.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1_0
Fixed in: 1.01



Subject: Error in language detection - also warnings during make test
Download (untitled) / with headers
text/plain 627b
There is a bug in the detection of languages from properties in HTML-ParseBrowser-1_0: for my $lang (keys %lang) { if (/^$lang\-/) { my $l; ($l, undef) = split /\-/; push @{$browser->{languages}}, $lang{$l} || $1; push @{$browser->{langs}}, $1; } The code pushes $1 (one) onto the arrays, rather than $l (lowercase l). This causes a warning during make test. Other parts of the code also generate warnings during make test, but don't seem to indicate actual bugs. The attached patch fixes both the above bug and the warnings.
Subject: html-parsebrowser.patch
--- lib/HTML/ParseBrowser.pm~ 2008-07-16 17:56:08.000000000 -0400 +++ lib/HTML/ParseBrowser.pm 2008-10-16 11:09:21.000000000 -0400 @@ -34,10 +34,12 @@ if ($useragent =~ s/\((.*)\)//) { $browser->{detail} = $1; + $browser->{properties} = [split /;\s+/, $browser->{detail}]; + } else { + $browser->{properies} = []; } $browser->{useragents} = [grep /\//, split /\s+/, $useragent]; - $browser->{properties} = [split /;\s+/, $browser->{detail}]; for (@{$browser->{useragents}}) { my ($br, $ver) = split /\//; @@ -144,8 +146,8 @@ if (/^$lang\-/) { my $l; ($l, undef) = split /\-/; - push @{$browser->{languages}}, $lang{$l} || $1; - push @{$browser->{langs}}, $1; + push @{$browser->{languages}}, $lang{$l} || $l; + push @{$browser->{langs}}, $l; } push @{$browser->{languages}}, $lang{$_} if /^$lang$/; @@ -181,12 +183,18 @@ $langs_in{$_}++; } + if (scalar keys %langs_in) { ($browser->{lang}) = sort {$langs_in{$a} <=> $langs_in{$b}} keys %langs_in; $browser->{language} = $lang{$browser->{lang}} || $browser->{lang}; + } delete $browser->{language} unless $browser->{language}; return $browser; } +# define DESTROY so AUTOLOAD is not called +sub DESTROY { +} + sub AUTOLOAD { my $obj = shift; my $me = lc $AUTOLOAD;
Subject: html-parsebrowser-warnings.txt
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/HTML-ParseBrowser....ok 1/17Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12. Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12. Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12. Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12. Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12. Use of uninitialized value in split at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 40, <DATA> line 12. Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12. Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12. Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12. Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12. Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12. Use of uninitialized value in scalar dereference at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 202, <DATA> line 12 during global destruction. t/HTML-ParseBrowser....ok All tests successful. Files=1, Tests=17, 0 wallclock secs ( 0.04 cusr + 0.00 csys = 0.04 CPU)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.