Subject: | login() should not try authenticate() if auth is empty or undef |
Date: | Fri, 13 Feb 2009 21:13:00 -0500 |
To: | bug-Mail-IMAPClient [...] rt.cpan.org |
From: | Phil Lobbes <phil [...] perkpartners.com> |
Here's a minor bug against 3.13...
The 2.2.9 version of login() would not call authenticate() unless
$self->Authmechanism was set to something that would evaluate to true.
Old 2.x code login:
return $self->authenticate($self->Authmechanism,$self->Authcallback)
if $self->{Authmechanism};
However, the 3.x login() will try call authenticate() even if the
Authmechanism is set to "". For backwards compatibility, we probably
shouldn't do that.
Code in 3.x login:
return $self->authenticate($auth, $self->Authcallback)
if $auth ne 'LOGIN';
If the Authmechanism is set to "" we send an invalid authenticate
request. Granted, undef would be a better value than "" if you didn't
want the mechanism set to anything, but there is no practical use for
trying to call authenticate() if the Authmechanism value doesn't
evaluate to true (I doubt there will be a valid mechanism named "0" any
time soon).
Thanks!
Phil
Here's the simple patch:
[plobbes@ps01 tmp]$ diff -u IMAPClient.pm.ORIG IMAPClient.pm
--- IMAPClient.pm.ORIG 2009-02-13 21:00:02.000000000 -0500
+++ IMAPClient.pm 2009-02-13 21:00:34.000000000 -0500
@@ -331,7 +331,7 @@
{ my $self = shift;
my $auth = $self->Authmechanism;
return $self->authenticate($auth, $self->Authcallback)
- if $auth ne 'LOGIN';
+ if $auth and $auth ne 'LOGIN';
my $passwd = $self->Password;
if($passwd =~ m/\W/) # need to quote