Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: ekoontz [...] mailfrontier.com
Cc:
AdminCc:

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



Date: Wed, 29 Dec 2004 15:16:31 -0800
From: Eugene Koontz <ekoontz [...] mailfrontier.com>
To: bug-Mail-IMAPClient [...] rt.cpan.org
Subject: bug and patch for IMAPClient.pm
Hi, I found this Mail::IMAPClient module to be very useful and appreciate your work on it. I seem to have found a bug (using module version 2.2.9) in parsing LIST server responses to find the folder delimitor in the separator() function here : my $list = (grep(/^\*\s+LIST\s+/,($self->list(undef,$target)||("NO")) ))[0] || qq("/"); my $s = (split(/\s+/,$list))[3]; The split() will search for the third non-whitespace region. However, this seems to fail if the server response is something like : * LIST (\NoInferiors \Marked) "/" Trash In this case, the $s would be "\Marked", rather than : "/". So, here (attached and also included as text) is a patch that searches for the first non-whitespace region AFTER the parenthesis region : --- IMAPClient.pm.orig 2003-07-02 10:28:54.000000000 -0700 +++ IMAPClient.pm 2004-12-29 15:02:35.000000000 -0800 @@ -336,9 +336,8 @@ # The fact that the response might end with {123} doesn't really matter here: unless (exists $self->{"$target${;}SEPARATOR"}) { - my $list = (grep(/^\*\s+LIST\s+/,($self->list(undef,$target)||("NO")) ))[0] || - qq("/"); - my $s = (split(/\s+/,$list))[3]; + my $list = ($self->list(undef,$target))[0] || "NO"; + my $s = ($list =~ m/^\*\s+LIST\s+\([^\)]+\)\s+(\S+)/)[0] || qq("/"); defined($s) and $self->{"$target${;}SEPARATOR"} = ( $s eq 'NIL' ? 'NIL' : substr($s, 1,length($s)-2) ); } Thanks for considering this, Eugene
--- IMAPClient.pm.orig 2003-07-02 10:28:54.000000000 -0700 +++ IMAPClient.pm 2004-12-29 15:02:35.000000000 -0800 @@ -336,9 +336,8 @@ # The fact that the response might end with {123} doesn't really matter here: unless (exists $self->{"$target${;}SEPARATOR"}) { - my $list = (grep(/^\*\s+LIST\s+/,($self->list(undef,$target)||("NO")) ))[0] || - qq("/"); - my $s = (split(/\s+/,$list))[3]; + my $list = ($self->list(undef,$target))[0] || "NO"; + my $s = ($list =~ m/^\*\s+LIST\s+\([^\)]+\)\s+(\S+)/)[0] || qq("/"); defined($s) and $self->{"$target${;}SEPARATOR"} = ( $s eq 'NIL' ? 'NIL' : substr($s, 1,length($s)-2) ); }
New maintainer. Yes, your patch is an improved... the code was horrible and broken. I have changed it a little further, into my $label = $target . $; . SEPARATOR; unless(exists $self->{$label}) { my $list = ($self->list(undef,$target))[0] || "NO"; my $s = $list =~ m/^\*\s+LIST\s+\([^\)]+\)\s+(\S+)/ ? $1 : qq("/"); $self->{$label} = ($s eq 'NIL' ? 'NIL' : substr($s, 1,length($s)-2)) if defined $s; } $self->{$label}; Thanks for the patch... will be in 2.99_02