Skip Menu |

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

Report information
The Basics
Id: 92177
Status: resolved
Priority: 0/
Queue: Net-IMAP-Server

People
Owner: Nobody in particular
Requestors: lubo.rintel [...] gooddata.com
Cc:
AdminCc:

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



Subject: Warining in parse_options() due to improper use of Regexp::Common
Hi, the following test case produces a warning for me: use Net::IMAP::Server::Command; use strict; use warnings; my $c = new Net::IMAP::Server::Command; $c->parse_options ('MESSAGES UNSEEN YOLO UIDVALIDITY UIDNEXT'); Use of uninitialized value $_ in pattern match (m//) at lib/Net/IMAP/Server/Command.pm line 141. The problem lies in the following code: grep {/\S/} split /($RE{delimited}{-delim=>'"'}{-esc=>'\\'}|$RE{balanced}{-parens=>'()'}|\S+$RE{balanced}{-parens=>'()[]<>'}|\S+)/, Regexp::Common returns a regular expression with a capture group and split() considers it to be a separator, resulting in undefined strings being fed to grep(): $ perl -e 'use Regexp::Common "RE_ALL"; print RE_balanced(-parens=>"<>");' (?^:((?:\<(?:(?>[^\<\>]+)|(?-1))*\>))) ^^^^^ a capture group here. A quick way to silence it it the following: - grep {/\S/} + grep {defined $_ and /\S/} though I don't know whether the code functions as intended. I have no better idea though.
CC: Lubomir Rintel <lkundrak [...] v3.sk>
Subject: [rt.cpan.org #92177] [PATCH 1/2] Add test for STATUS
Date: Wed, 15 Jan 2014 19:59:01 +0100
To: bug-Net-IMAP-Server [...] rt.cpan.org
From: Lubomir Rintel <lkundrak [...] v3.sk>
Just for the purpose of having a test that uses tokens enclosed in parentheses. Parsing of those yields incorrect results with Regexp::Common version that returns expressions with capture groups and STATUS commands complains about extra arguments in such case. --- t/rfc-6.3.10-status.t | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 t/rfc-6.3.10-status.t diff --git a/t/rfc-6.3.10-status.t b/t/rfc-6.3.10-status.t new file mode 100644 index 0000000..310458d --- /dev/null +++ b/t/rfc-6.3.10-status.t @@ -0,0 +1,18 @@ +use lib 't/lib'; +use strict; +use warnings; + +use Net::IMAP::Server::Test; +my $t = "Net::IMAP::Server::Test"; + +$t->start_server_ok; +$t->connect_ok; +$t->cmd_ok("LOGIN username password"); +$t->cmd_like( + "STATUS INBOX (MESSAGES UNSEEN)", + '* STATUS "INBOX" (UNSEEN 0 MESSAGES 0)', + "tag OK STATUS COMPLETED", +); +$t->disconnect; + +done_testing; -- 1.8.3.1
CC: Lubomir Rintel <lkundrak [...] v3.sk>
Subject: [rt.cpan.org #92177] [PATCH 2/2] Fix option parsing
Date: Wed, 15 Jan 2014 19:59:02 +0100
To: bug-Net-IMAP-Server [...] rt.cpan.org
From: Lubomir Rintel <lkundrak [...] v3.sk>
Regex::Common can produce a capture group, which would result in extra matches when passed to split(). We now split the options string manually. --- lib/Net/IMAP/Server/Command.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Net/IMAP/Server/Command.pm b/lib/Net/IMAP/Server/Command.pm index 15c5c41..4d21bcd 100644 --- a/lib/Net/IMAP/Server/Command.pm +++ b/lib/Net/IMAP/Server/Command.pm @@ -137,14 +137,16 @@ sub parse_options { return $self->_parsed_options if not defined $str and not defined $self->options_str; + my $options_str = defined $str ? $str : $self->options_str; my @parsed; - for my $term ( - grep {/\S/} - split - /($RE{delimited}{-delim=>'"'}{-esc=>'\\'}|$RE{balanced}{-parens=>'()'}|\S+$RE{balanced}{-parens=>'()[]<>'}|\S+)/, - defined $str ? $str : $self->options_str + while ( + my @cap = $options_str =~ + /($RE{delimited}{-delim=>'"'}{-esc=>'\\'}|$RE{balanced}{-parens=>'()'}|\S+$RE{balanced}{-parens=>'()[]<>'}|\S+)(.*)/ ) { + my $term = $1; + $options_str = pop @cap; + if ( $term =~ /^$RE{delimited}{-delim=>'"'}{-esc=>'\\'}{-keep}$/ ) { my $value = $3; $value =~ s/\\([\\"])/$1/g; -- 1.8.3.1
Subject: Re: [rt.cpan.org #92177] Warining in parse_options() due to improper use of Regexp::Common
Date: Sun, 26 Jan 2014 19:19:50 -0500
To: bug-Net-IMAP-Server [...] rt.cpan.org
From: Alex Vandiver <alex [...] chmrr.net>
On Wed, 2014-01-15 at 13:05 -0500, Lubomir Rintel via RT wrote: Show quoted text
> the following test case produces a warning for me: [snip]
Thanks for the report, and the patches. I've applied alternate forms of both, and released Net-IMAP-Server-1.37, which should be compatible with the latest Regexp::Common. Tangentially, I'm unclear what to make of https://github.com/lkundrak/net-imap-server/commit/3189edf4 - Alex
Subject: Re: [rt.cpan.org #92177] Warining in parse_options() due to improper use of Regexp::Common
Date: Mon, 27 Jan 2014 08:48:31 +0100
To: bug-Net-IMAP-Server [...] rt.cpan.org
From: Lubomir Rintel <lubo.rintel [...] gooddata.com>
On Mon, Jan 27, 2014 at 1:20 AM, Alex Vandiver via RT <bug-Net-IMAP-Server@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=92177 > > > On Wed, 2014-01-15 at 13:05 -0500, Lubomir Rintel via RT wrote:
>> the following test case produces a warning for me: [snip]
> > Thanks for the report, and the patches. I've applied alternate forms of > both, and released Net-IMAP-Server-1.37, which should be compatible with > the latest Regexp::Common.
Thank you! Show quoted text
> Tangentially, I'm unclear what to make of > https://github.com/lkundrak/net-imap-server/commit/3189edf4
It's a testcase for https://bugzilla.redhat.com/show_bug.cgi?id=1053465 I couldn't find out what version of Net::IMAP::Server yields results that I've observed in mail.muni.cz mail server installation, so I just deliberately broke master build to mimic the faulty behavior for QA purposes.