Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: rasjidw [...] openminddev.net
Cc:
AdminCc:

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



Subject: Bug in separator function
Distribution: Mail::IMAPClient version 2.2.9 Perl: 5.8.0 OS: Linux 2.4.20 (SuSE 8.2) For imap servers where there is no namespace support (or at least the DBMail and Binc Imap servers) the 'separator' funciton seems to fail. I attach a simple test case program. The relevant output from the testcase is as follows: $ ./imaptest ... Read: 2 OK CAPABILITY completed 2 NO NAMESPACE not supported by localhost 2 NO NAMESPACE not supported by localhost at ./imaptest line 24 Sending: 3 LIST "" "" Sent 14 bytes Read: * LIST (\NoSelect) "/" "" Read: 3 OK LIST completed Use of uninitialized value in concatenation (.) or string at ./imaptest line 26. Separator returned is '' The fix I did for imapsync (which uses your library) was based on the parsing of the LIST command that you do in the 'folder' function. However, I don't understand perl enough to offer a fix to your current separator method directly. I hope all this helped. Cheers, Rasjid.
Download imaptest
application/x-perl 608b

Message body not shown because it is not plain text.

New maintainer On Sat Dec 13 05:50:19 2003, guest wrote: Show quoted text
> Distribution: Mail::IMAPClient version 2.2.9 > Perl: 5.8.0 > OS: Linux 2.4.20 (SuSE 8.2) > > For imap servers where there is no namespace support (or at least the > DBMail and Binc Imap servers) the 'separator' funciton seems to fail.
Show quoted text
> The fix I did for imapsync (which uses your library) was based on the > parsing of the LIST command that you do in the 'folder' function. > > However, I don't understand perl enough to offer a fix to your current > separator method directly.
I do not see that fix in the current imapsync. if you have it somewhere, feel invited to submit it again. I will rewrite it to "real" Perl if needed. == MarkOv
Subject: Re: [rt.cpan.org #4662] Bug in separator function
Date: Thu, 25 Oct 2007 09:14:20 +1000
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: Rasjid Wilcox <rasjidw [...] openminddev.net>
Hi Mark, It has been several years, so I have no recollection of the context for this. I do remember migrating mail from one imap server to another, which is that imapsync is used for. I have found two patch files for imapsync that I have sitting around from that time. I don't even know what the source of the patches is. I presumably did the changes myself, but I really don't know for sure. Anyway, for what it is worth, they are attached. Cheers, Rasjid. Mark Overmeer via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=4662 > > > New maintainer > > On Sat Dec 13 05:50:19 2003, guest wrote: >
>> Distribution: Mail::IMAPClient version 2.2.9 >> Perl: 5.8.0 >> OS: Linux 2.4.20 (SuSE 8.2) >> >> For imap servers where there is no namespace support (or at least the >> DBMail and Binc Imap servers) the 'separator' funciton seems to fail. >>
> >
>> The fix I did for imapsync (which uses your library) was based on the >> parsing of the LIST command that you do in the 'folder' function. >> >> However, I don't understand perl enough to offer a fix to your current >> separator method directly. >>
> > I do not see that fix in the current imapsync. if you have it > somewhere, feel invited to submit it again. I will rewrite it to > "real" Perl if needed. > > == MarkOv > > >
--- /usr/local/bin/imapsync 2003-11-08 01:09:25.000000000 +1100 +++ imapsync 2003-11-11 00:07:13.000000000 +1100 @@ -248,19 +248,37 @@ @f_folders = (scalar(@folder)) ? @folder : @{$from->folders()}; # what are the private folders separators for each server ? -my $f_sep = $from->namespace()->[0][0][1]; -my $t_sep = $to->namespace()->[0][0][1]; +my $f_sep = $from->separator(); + +unless ($f_sep) { + print "No from namespace support. Falling back on list parse.\n"; + my @f_list = $from->list(); + $debug and print "From list[0] : [$f_list[0]]\n"; + if ($f_list[0] =~ /"(.)"/) { + $f_sep = $1; + } + +} + +my $t_sep = $to->separator(); + +unless ($t_sep ) { + print "No to namespace support. Falling back on list parse.\n"; + my @t_list = $to->list(); + $debug and print "To list[0] : [$t_list[0]]\n"; + if ($t_list[0] =~ /"(.)"/) { + $t_sep = $1; + } +} print "From separator : [$f_sep]\n"; print "To separator : [$t_sep]\n";
--- /usr/local/bin/imapsync 2003-11-08 01:09:25.000000000 +1100 +++ imapsync 2003-12-13 20:24:36.000000000 +1100 @@ -195,6 +195,23 @@ die "$option option must be used, run $0 --help for help\n"; } +sub sepfromlist { + my $imapconn = shift; + my @list = $imapconn->list(); + my $sep; + $debug and print "list[0] : [$list[0]]\n"; + if ($list[0] =~ + / ^\*\s+LIST # * LIST + \s+\([^\)]*\)\s+ # (Flags) + (?:"([^"]*)"|(NIL))\s+ # "delimiter" or NIL + (?:"([^"]*)"|(.*))\x0d\x0a$ # Name or "Folder name" + /ix) { + $sep = $1; + } + # FIXME: should probably do something if $sep is NIL?? + return $sep; +} + $host1 || missing_option("--host1") ; $port1 = (defined($port1)) ? $port1 : 143; $user1 || missing_option("--user1"); @@ -248,8 +265,19 @@ @f_folders = (scalar(@folder)) ? @folder : @{$from->folders()}; # what are the private folders separators for each server ? -my $f_sep = $from->namespace()->[0][0][1]; -my $t_sep = $to->namespace()->[0][0][1]; +my $f_sep = $from->separator(); + +unless ($f_sep) { + print "No 'from' separator returned. Falling back on list parse.\n"; + $f_sep = sepfromlist($from); +} + +my $t_sep = $to->separator(); + +unless ($t_sep) { + print "No 'to' separator returned. Falling back on list parse.\n"; + $t_sep = sepfromlist($to); +} print "From separator : [$f_sep]\n"; print "To separator : [$t_sep]\n";
Thanks, Rasjid. apparently, you implement the same thing for $to and $from: two chances to make a mistake. Anyway: your example showed me a buglet I introduced in my conversion. The LIST fallback is already in Mail::IMAPClient. My separator method now reads this: sub separator { my ($self, $target) = @_; unless(defined $target) { # separator is namespace's 1st thing's 1st thing's 2nd thing: my $sep = $self->namespace->[0][0][1]; return $sep if $sep; $target = ''; } return $self->{separators}{$target} if $self->{separators}{$target}; my $list = $self->list(undef, $target) || ''; my $s = $list =~ /^\*\s+LIST\s+\([^)]*\)\s+(\S+)/ ? $1 : '/'; $s =~ s/^\"(.*?)\"$/$1/; $self->{separators}{$target} = $s; } Thanks for looking this up for me!