Skip Menu |

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

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

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

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



Subject: is_parent() code doesn't match exactly the documentation.
Date: Sun, 19 Apr 2015 15:41:36 +0200
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: Gilles LAMIRAL <gilles.lamiral [...] laposte.net>
Hello Phil, The code within is_parent() doesn't match exactly the documentation. http://search.cpan.org/~plobbes/Mail-IMAPClient-3.35/lib/Mail/IMAPClient.pod#is_parent The documentation says: "It returns a value that indicates whether or not the folder has children. The value it returns is either 1) a true value (indicating that the folder has children), 2) 0 if the folder has no children at this time, or 3) undef if the folder is not permitted to have children." The code says it return 0 if the folder is not permitted to have children or if the folder has no children at this time, which is not very useful. RFC says: 7.2.2. LIST Response Contents: name attributes hierarchy delimiter name The LIST response occurs as a result of a LIST command. It returns a single name that matches the LIST specification. There can be multiple LIST responses for a single LIST command. Four name attributes are defined: \Noinferiors It is not possible for any child levels of hierarchy to exist under this name; no child levels exist now and none can be created in the future. The API described by the documentation makes sense with the RFC and practical cases so I suggest to fix the code instead of the doc. Thanks in advance Phil. - return 0 if $rec->{attrs} =~ /\bNoInferior\b/i; + return undef if $rec->{attrs} =~ /\bNoInferior\b/i; Current Mail-IMAPClient-3.35 gives: sub is_parent { my ( $self, $folder ) = ( shift, shift ); my $list = $self->list( undef, $folder ) or return undef; my $attrs; foreach my $resp (@$list) { my $rec = $self->_list_or_lsub_response_parse($resp); next unless defined $rec->{attrs}; return 0 if $rec->{attrs} =~ /\bNoInferior\b/i; $attrs = $rec->{attrs}; } if ($attrs) { return 1 if $attrs =~ /HasChildren/i; return 0 if $attrs =~ /HasNoChildren/i; } else { $self->_debug( join( "\n\t", "no attrs for '$folder' in:", @$list ) ); } # BUG? This may be overkill for normal use cases... # flag not supported or not returned for some reason, try via folders() my $sep = $self->separator($folder) || $self->separator(undef); return undef unless defined $sep; my $lead = $folder . $sep; my $len = length $lead; scalar grep { $lead eq substr( $_, 0, $len ) } $self->folders; } -- Au revoir, 09 51 84 42 42 Gilles Lamiral. France, Baulon (35580) 06 20 79 76 06
Hi Gilles! Thanks for the report. I'll look into getting this fixed in the next release.
Patched in https://github.com/plobbes/mail-imapclient/commit/ac1213d21e9e34c0055ca200846f79e83b406af1 - tidied up docs and added a couple of test cases too (could still be better though)
CC: DJKERNEN [...] cpan.org
Subject: Re: [rt.cpan.org #103823] is_parent() code doesn't match exactly the documentation.
Date: Thu, 13 Aug 2015 20:26:16 +0200
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: Gilles LAMIRAL <gilles.lamiral [...] laposte.net>
Big thanks Phil! Still no amazon wishlist nor paypal account? On 13/08/2015 00:26, Phil Pearl (Lobbes) via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=103823 > > > Patched in https://github.com/plobbes/mail-imapclient/commit/ac1213d21e9e34c0055ca200846f79e83b406af1 > > - tidied up docs and added a couple of test cases too (could still be better though) >
-- Au revoir, 09 51 84 42 42 Gilles Lamiral. France, Baulon (35580) 06 20 79 76 06