Skip Menu |

This queue is for tickets about the POE-Component-IRC CPAN distribution.

Report information
The Basics
Id: 79343
Status: open
Priority: 0/
Queue: POE-Component-IRC

People
Owner: Nobody in particular
Requestors: jensheremans [...] gmail.com
Cc:
AdminCc:

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



Subject: Possible encoding bug in POE::Component::IRC::Plugin::Logger
Date: Sat, 1 Sep 2012 18:53:15 +0200
To: bug-poe-component-irc [...] rt.cpan.org
From: Jens Heremans <jensheremans [...] gmail.com>
Hello I think I have encountered a bug in POE::Component::IRC::Plugin::Logger related to character encoding. Whenever I add this plugin my bot seems unable to properly send unicode characters to irc, this seems to be caused by some char transcoding from the Logger plugin. When I set my script to 'use utf8' the characters do display properly but the logger throws an error (found in the chat log below) and doesn't log the message to file. Otherwise the messages log to file just fine, but don't display properly in IRC. Below is a short chat log about this issue from #poe on irc.perl.org 18:24:07 flasheh_ : Well then, I'm having issues with the Logger Show quoted text
>> plugin from poco-irc. It seems to mess up the
> > character encoding because unicode chars don't
>> display properly when the plugin is enabled.
> > 18:24:28 flasheh_ : I've been trying to figure this out for a while,
>> and I don't know why or how this is happening
> > 18:24:43 dngor : To where is it logging? > > 18:25:38 flasheh_ : To a file. But the logs aren't the issue, it are
>> the actual messages sent to IRC that don't
> > display properly > > 18:26:46 dngor : So when you turn on logging, things that you send
>> to channel get garbled, and when you turn
> > off logging, they ungarble? > > 18:27:09 flasheh_ : pretty much > > 18:29:59 dngor : I see in its description that it does some
>> character set transcoding. That might be bleeding
> > out into the rest of the program. > > 18:30:16 dngor : I don't see where it's decoding the text, though. > > 18:32:59 flasheh_ : Well, one thing I've found it that if I set 'use
>> utf8' the chars display fine but the logger
> > plugin throws an error > > 18:33:04 flasheh_ : S_bot_public call on plugin 'Logger' failed:
>> Cannot decode string with wide characters at
> >
>> /usr/lib64/perl5/site_perl/5.12.4/x86_64-linux/Encode.pm line 175.
> > 18:35:30 dngor : I think this one needs to be reported as a bug. > >
I hope I have provided enough information. Thanks in advance. Jens Heremans
Subject: [rt.cpan.org #79343]
Date: Wed, 26 Apr 2017 05:04:05 +0300
To: bug-POE-Component-IRC [...] rt.cpan.org
From: xcdc dxcx <xcdcdxcx [...] gmail.com>
Hello. I think There are actually two bugs, one described by original report and one related. Bug #1: POE::Component::IRC::Plugin::Logger modifies data that other plugins will be working with. This happens due to writing into alias. Example (there are several): for my $chan (@{ $channels }) { $chan = decode_irc($chan); Bug #2: POE::Component::IRC::Plugin::Logger attempts to decode already decoded data. This bug I have discovered while investigating the first one. If the data is sent to irc as: $irc->yield('privmsg', $recipient, $text); and $recipient and $text are unicode characters, then S_bot_* handlers will receive the data as characters too. Attempting to apply decode_irc (in _normalize) to this data results in data being not logged (completely silent crash, unless your $irc has plugin_debug enabled). The following patch attempts to fix both of these issues by adding using local variables instead of writing into aliases, and by introducing a parameter to _normalize to conditionally turn off decoding. diff --git a/lib/POE/Component/IRC/Plugin/Logger.pm b/lib/POE/Component/IRC/Plugin/Logger.pm index e6a90a0..934bf75 100644 --- a/lib/POE/Component/IRC/Plugin/Logger.pm +++ b/lib/POE/Component/IRC/Plugin/Logger.pm @@ -119,8 +119,8 @@ sub S_ctcp_action { $self->_log_entry($sender, action => $sender, $msg); } else { - $recipient = decode_irc($recipient); - $self->_log_entry($recipient, action => $sender, $msg); + my $decoded_recipient = decode_irc($recipient); + $self->_log_entry($decoded_recipient, action => $sender, $msg); } } return PCI_EAT_NONE; @@ -137,8 +137,8 @@ sub S_notice { $self->_log_entry($sender, notice => $sender, $msg); } else { - $target = decode_irc($target); - $self->_log_entry($target, notice => $sender, $msg); + my $decoded_target = decode_irc($target); + $self->_log_entry($decoded_target, notice => $sender, $msg); } } return PCI_EAT_NONE; @@ -148,10 +148,9 @@ sub S_notice { sub S_bot_action { my ($self, $irc) = splice @_, 0, 2; my $recipients = ${ $_[0] }; - my $msg = $self->_normalize(${ $_[1] }); + my $msg = $self->_normalize(${ $_[1] }, 1); for my $recipient (@{ $recipients }) { - $recipient = decode_irc($recipient); $self->_log_entry($recipient, action => $irc->nick_name(), $msg); } return PCI_EAT_NONE; @@ -160,7 +159,7 @@ sub S_bot_action { sub S_bot_msg { my ($self, $irc) = splice @_, 0, 2; my $recipients = ${ $_[0] }; - my $msg = $self->_normalize(${ $_[1] }); + my $msg = $self->_normalize(${ $_[1] }, 1); for my $recipient (@{ $recipients }) { $self->_log_entry($recipient, privmsg => $irc->nick_name(), $msg); @@ -171,10 +170,9 @@ sub S_bot_msg { sub S_bot_public { my ($self, $irc) = splice @_, 0, 2; my $channels = ${ $_[0] }; - my $msg = $self->_normalize(${ $_[1] }); + my $msg = $self->_normalize(${ $_[1] }, 1); for my $chan (@{ $channels }) { - $chan = decode_irc($chan); $self->_log_entry($chan, privmsg => $irc->nick_name(), $msg); } return PCI_EAT_NONE; @@ -183,10 +181,9 @@ sub S_bot_public { sub S_bot_notice { my ($self, $irc) = splice @_, 0, 2; my $targets = ${ $_[0] }; - my $msg = $self->_normalize(${ $_[1] }); + my $msg = $self->_normalize(${ $_[1] }, 1); for my $target (@{ $targets }) { - $target = decode_irc($target); $self->_log_entry($target, notice => $irc->nick_name(), $msg); } return PCI_EAT_NONE; @@ -228,8 +225,8 @@ sub S_nick { my $channels = ${ $_[2] }; for my $chan (@{ $channels }) { - $chan = decode_irc($chan); - $self->_log_entry($chan, nick_change => $old_nick, $new_nick); + my $decoded_chan = decode_irc($chan); + $self->_log_entry($decoded_chan, nick_change => $old_nick, $new_nick); } return PCI_EAT_NONE; } @@ -252,8 +249,8 @@ sub S_public { my $msg = $self->_normalize(${ $_[2] }); for my $chan (@{ $channels }) { - $chan = decode_irc($chan); - $self->_log_entry($chan, privmsg => $sender, $msg); + my $chan_decoded = decode_irc($chan); + $self->_log_entry($chan_decoded, privmsg => $sender, $msg); } return PCI_EAT_NONE; } @@ -265,8 +262,8 @@ sub S_quit { my $channels = ${ $_[2] }; for my $chan (@{ $channels }) { - $chan = decode_irc($chan); - $self->_log_entry($chan, quit => $quitter, "$user\@$host", $msg); + my $chan_decoded = decode_irc($chan); + $self->_log_entry($chan_decoded, quit => $quitter, "$user\@$host", $msg); } return PCI_EAT_NONE; } @@ -405,8 +402,8 @@ sub _open_log { } sub _normalize { - my ($self, $line) = @_; - $line = decode_irc($line); + my ($self, $line, $skip_decode) = @_; + $line = decode_irc($line) unless $skip_decode; $line = strip_color($line) if $self->{Strip_color}; $line = strip_formatting($line) if $self->{Strip_formatting}; return $line;