On Wed, Aug 15, 2007 at 05:15:07PM +0800, David Sobon wrote: > > The first patch ('fix_ev_has_null_type.patch')... I did come across a > few presumably non-standard IRC servers that sent unknown numeric > codes. Your second reason seems more plausible. I think the best > approach would be to print debugging info when $ev is undefined... to > find out how it happened. Or example IRC servers? Any pointers?
Sorry for the delay. I finally got around to testing this a bit, and it turns out that my IRC server also sends out a code that's unknown to Net::IRC: :<irc-server> 020 * :Please wait while we scan you for security. With this, I came up with the attached patch. It fixes two undefined value warnings and adds a debugging message mentioning the unknown code. I'll include this and the 'next-versus-return' patch into the next version and send them to the upstream bug tracker for the benefit of other distributions. Cheers, -- Niko Tyni [EMAIL PROTECTED]
#! /bin/sh /usr/share/dpatch/dpatch-run ## 60warnings_from_unknown_event.dpatch by Niko Tyni <[EMAIL PROTECTED]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Fix 'uninitialized value' warnings from unknown response codes. ## DP: See #437474 @DPATCH@ diff -urNad libnet-irc-perl~/Connection.pm libnet-irc-perl/Connection.pm --- libnet-irc-perl~/Connection.pm 2007-09-16 21:35:56.000000000 +0300 +++ libnet-irc-perl/Connection.pm 2007-09-16 21:35:59.000000000 +0300 @@ -467,6 +467,7 @@ my $ev; if (ref $event) { $ev = $event->type; + $ev = "" if !$ev; } elsif (defined $event) { $ev = $event; $event = Net::IRC::Event->new($event, '', '', ''); @@ -1126,11 +1127,15 @@ $from = substr $from, 1 if $from =~ /^:/; - return Net::IRC::Event->new( $type, + my $event = Net::IRC::Event->new( $type, $from, '', 'server', @stuff ); + if (!$event->type and $self->{_debug}) { + carp("Unknown code $type received") ; + } + return $event; } # Helps you flee those hard-to-stand channels. @@ -1584,6 +1589,8 @@ croak "You EEEEEDIOT!!! Not enough args to _default()!"; } + return 1 if !$event->type; + # Reply to PING from server as quickly as possible. if ($event->type eq "ping") { $self->sl("PONG " . (CORE::join ' ', $event->args));