Skip Menu |

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

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

People
Owner: PLOBBES [...] cpan.org
Requestors: skunk [...] iskunk.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 3.12
  • 3.19
Fixed in: 3.20



Subject: Cannot LOGIN with empty password
I have an IMAP server (Dovecot) where the login credentials are username = "anonymous", password = "". Fetchmail connects correctly with the following: ----8<---- fetchmail: IMAP< * OK Dovecot ready. fetchmail: IMAP> A0001 CAPABILITY fetchmail: IMAP< * CAPABILITY IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND UNSELECT LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS AUTH=PLAIN fetchmail: IMAP< A0001 OK Capability completed. fetchmail: IMAP> A0002 LOGIN "anonymous" * fetchmail: IMAP< A0002 OK Logged in. ---->8---- So, in my Mail::IMAPClient->new() call, I set User => 'anonymous', Password => '', and I get ----8<---- Using Mail::IMAPClient version 3.19 on perl 5.010000 Read: * OK Dovecot ready. Sending: 1 STATUS INBOX (MESSAGES) Sent 27 bytes Read: 1 BAD Error in IMAP command received by server. ERROR: 1 BAD Error in IMAP command received by server. at /tmp/Mail-IMAPClient-3.19/lib/Mail/IMAPClient.pm line 1316 ---->8---- It's not even doing the LOGIN. I made a small change to the bottom of Mail::IMAPClient::Socket(): - $self->User && $self->Password ? $self->login : $self; + $self->User && defined($self->Password) ? $self->login : $self; Now, I get ----8<---- Using Mail::IMAPClient version 3.19 on perl 5.010000 Read: * OK Dovecot ready. Sending: 1 LOGIN "anonymous" Sent 22 bytes Read: 1 BAD Error in IMAP command received by server. ERROR: 1 BAD Error in IMAP command received by server. at /tmp/Mail-IMAPClient-3.19/lib/Mail/IMAPClient.pm line 1316 ---->8---- So I made one more change, this time in Mail::IMAPClient::login(): ----8<---- @@ -371,6 +371,9 @@ $passwd =~ s/(["\\])/\\$1/g; $passwd = qq("$passwd"); } + if ( $passwd eq '' ) { + $passwd = '*'; + } $id = qq("$id") if $id !~ /^".*"$/; ---->8---- And finally, everything works: ----8<---- Using Mail::IMAPClient version 3.19 on perl 5.010000 Read: * OK Dovecot ready. Sending: 1 LOGIN "anonymous" * Sent 23 bytes Read: 1 OK Logged in. Sending: 2 STATUS INBOX (MESSAGES) Sent 27 bytes Read: * STATUS "INBOX" (MESSAGES 269) 2 OK Status completed. Sending: 3 LOGOUT Sent 10 bytes Read: * BYE Logging out 3 OK Logout completed. ---->8---- A proper patch file, against the 3.19 source, is attached. This issue was first observed on 3.12, as shipped with Ubuntu Jaunty, and confirmed on the latest 3.19.
Subject: imapclient-fix.patch
diff -ru Mail-IMAPClient-3.19.orig/lib/Mail/IMAPClient.pm Mail-IMAPClient-3.19/lib/Mail/IMAPClient.pm --- Mail-IMAPClient-3.19.orig/lib/Mail/IMAPClient.pm 2009-06-19 15:06:33.000000000 -0400 +++ Mail-IMAPClient-3.19/lib/Mail/IMAPClient.pm 2009-07-22 23:58:35.000000000 -0400 @@ -353,7 +353,7 @@ return $self; } - $self->User && $self->Password ? $self->login : $self; + $self->User && defined($self->Password) ? $self->login : $self; } sub login { @@ -371,6 +371,9 @@ $passwd =~ s/(["\\])/\\$1/g; $passwd = qq("$passwd"); } + if ( $passwd eq '' ) { + $passwd = '*'; + } $id = qq("$id") if $id !~ /^".*"$/;
Below is an alternative patch, as I believe making the password "*" is probably wrong and all that really needs to happen is that we quote the empty password. If you get a chance please test this alternative and let me know the results, thanks! Phil $ diff -u IMAPClient.pm.ORIG IMAPClient.pm --- IMAPClient.pm.ORIG 2009-06-19 14:51:37.703125000 -0400 +++ IMAPClient.pm 2009-07-23 10:44:29.004000000 -0400 @@ -367,7 +367,7 @@ return undef unless ( defined($passwd) and defined($id) ); - if ( $passwd =~ m/\W/ ) { # need to quote + if ( $passwd eq "" or $passwd =~ m/\W/ ) { # need to quote $passwd =~ s/(["\\])/\\$1/g; $passwd = qq("$passwd"); }
From: skunk [...] iskunk.org
On Thu Jul 23 10:48:16 2009, PLOBBES wrote: Show quoted text
> Below is an alternative patch, as I believe making the password "*"
is Show quoted text
> probably wrong and all that really needs to happen is that we quote
the Show quoted text
> empty password. If you get a chance please test this alternative and > let me know the results, thanks!
Yes, quoting the empty password does the trick: ----8<---- Using Mail::IMAPClient version 3.19 on perl 5.010000 Read: * OK Dovecot ready. Sending: 1 LOGIN "anonymous" "" Sent 24 bytes Read: 1 OK Logged in. Sending: 2 STATUS INBOX (MESSAGES) Sent 27 bytes Read: * STATUS "INBOX" (MESSAGES 270) 2 OK Status completed. Sending: 3 LOGOUT Sent 10 bytes Read: * BYE Logging out 3 OK Logout completed. ---->8----
Patch included w/release 3.20