Skip Menu |

This queue is for tickets about the Mail-IMAPClient CPAN distribution.

Report information
The Basics
Id: 127103
Status: resolved
Priority: 0/
Queue: Mail-IMAPClient

People
Owner: PLOBBES [...] cpan.org
Requestors: gilles [...] lamiral.info
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.2.9
Fixed in: 3.40



Subject: Issue in sub flags() in Mail/IMAPClient.pm when requesting a single message in array context.
Date: Thu, 13 Sep 2018 01:25:40 +0200
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: Gilles LAMIRAL <gilles [...] lamiral.info>
Hi Phil, Usage example: my @flags = $imap->flags( 42 ) ; In sub flags(), near the end, the line 2487 needs a small patch: # or did the guy want just one response? Return it if so - my $flagsref = $flagset->{$msgspec}; + my $flagsref = $flagset->{$msgspec} || []; Without this patch, a request to an unknown message, or a "void" response from the imap server, ends the program badly with: Can't use an undefined value as an ARRAY reference at W/Mail-IMAPClient-3.39/lib/Mail/IMAPClient.pm line 2488. Thanks in advance! -- Au revoir, Gilles Lamiral. France, Baulon (35580) mob 06 19 22 03 54 tel 09 51 84 42 42
Thanks for the report Gilles. I owe you an updated release, hopefully within a few weeks!
It's interesting to me that this line in sub flags() didn't return undef in the case you suggest: my $ref = $self->fetch( $msg, "FLAGS" ) or return undef; The server response must not be recognized as an error for your use case (Dovecot seems to return BAD Error ... for me). My change is slightly different than what you proposed: return wantarray ? @{ $flagsref || [] } : $flagsref; This way, if the server actually returns no FLAGS in the response at all, and the caller only asked about a single message/response we don't pretend that an empty set of flags was returned.
Fix is in latest push to https://sourceforge.net/p/mail-imapclient/git/ci/master/tree/ and will be in the next release.
Subject: [rt.cpan.org #127103] Issue in sub flags() in Mail/IMAPClient.pm when requesting a single message in array context.
Date: Fri, 28 Sep 2018 13:26:14 +0200
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: Gilles LAMIRAL <gilles [...] lamiral.info>
Hi Phil, Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=127103 > > > My change is slightly different than what you proposed: > > return wantarray ? @{ $flagsref || [] } : $flagsref; > > This way, if the server actually returns no FLAGS in the response at all, > and the caller only asked about a single message/response we don't pretend that an empty set of flags was returned.
Clever! Tested. -- Au revoir, Gilles Lamiral. France, Baulon (35580) mob 06 19 22 03 54 tel 09 51 84 42 42
Release 3.40 is out with the fix for this issue.