Subject: | Mailbox names are UTF7 |
Hi Phil,
(you may remember me as previous maintainer of the module) I am so glad you maintain Mail::IMAPClient so well ;-b Nearly never I need IMAP; it is hard to fix things when you do not use it yourself. However... at the moment I have to rewrite code which is based on "our" powerful module.
I have an issue. In the code which I have to rework, I read this:
use Encode::IMAPUTF7;
$mailbox = encode('IMAP-UTF-7', decode_entities $mailbox) if $mailbox;
$archiveMailbox = encode('IMAP-UTF-7', decode_entities $archiveMailbox) if $archiveMailbox;
Reading http://www.fetchmail.info/Mailbox-Names-UTF7.html I think this code is correct: the perl internal string must be converted explicitly to UTF7. I do not see this in the code.
This is *not* possible.
encode('IMAP-UTF-7', encode('IMAP-UTF-7', $anything))
So: it is not too straight-forward to solve. However, reading Encode::IMAPUTF7 it seems that "our" module will already break when a mailbox name with /\&.*\-/ is used. This is a clear indicator for being IMAP-UTF-7 encoded. So, what about
sub select {
my ( $self, $target ) = @_;
defined $target or return undef;
+ my $mailbox = $target =~ /\&.*\-/ ? $target : encode('IMAP-UTF-7', $target);
- my $qqtarget = $self->Quote($target);
+ my $qqtarget = $self->Quote($mailbox);
But there are more spots, like "list" to do the reverse.
Another (none tricky, less DWIMmy) solution would be to add an option. For instance "UnicodeNames"
What do you think?