Subject: | search command failed to parse Dovecot in-progress replies |
Date: | Sun, 14 Apr 2013 11:29:25 +0200 |
To: | bug-Net-IMAP-Client [...] rt.cpan.org |
From: | Tullio Andreatta ML <t.andreatta [...] troppoavanti.it> |
When Dovecot rebuild stale indexes on big mailbox, imap server reply
with an in-progress informational message (maybe to avoid client
timeout).
Session example:
<<< 30 SEARCH HEADER Message-ID 9832228.2013040417193@o--o.it
Show quoted text
>>> * Searched 42% of the mailbox, ETA 1:32
>>> * Searched 88% of the mailbox, ETA 0:29
>>> * SEARCH 901
>>> 30 OK Search completed (143.031 secs).
Net::IMAP::Client failed to correctly parse that reply, since
only the first '*' line is scanned.
--- /Net/IMAP/Client.pm, line 311-320 ---
my ($ok, $lines) = $self->_tell_imap($cmd => "$sort$charset
$criteria", 1);
if ($ok) {
# it makes no sense to employ the full token parser here
my $line = $lines->[0]->[0];
$line =~ s/^\*\s+(?:SEARCH|SORT)\s+//ig;
$line =~ s/\s*$//g;
return [ map { $_ + 0 } split(/\s+/, $line) ];
}
return undef;
My solution: parse lines until (SEARCH|SORT) match is found.
--- /usr/share/perl5/Net/IMAP/Client.pm 2013-04-14 07:54:37 +0200
+++ Net/IMAP/Client.pm 2013-04-14 10:00:06 +0200
@@ -311,10 +311,12 @@
my ($ok, $lines) = $self->_tell_imap($cmd => "$sort$charset
$criteria", 1);
if ($ok) {
# it makes no sense to employ the full token parser here
- my $line = $lines->[0]->[0];
- $line =~ s/^\*\s+(?:SEARCH|SORT)\s+//ig;
- $line =~ s/\s*$//g;
- return [ map { $_ + 0 } split(/\s+/, $line) ];
+ foreach my $line (@{$lines->[0]}) {
+ if ($line =~ s/^\*\s+(?:SEARCH|SORT)\s+//ig) {
+ $line =~ s/\s*$//g;
+ return [ map { $_ + 0 } split(/\s+/, $line) ];
+ }
+ }
}
return undef;