From: Guilhem Moulin Date: Sun, 9 Aug 2015 18:38:30 +0000 (+0200) Subject: Add support for SASL-IR (RFC 4959) to save a round-trip in AUTHENTICATE commands. X-Git-Url: https://git.g-eek.se/?a=commitdiff_plain;h=b1985240f59a22b27824c9fdcb79998a1c7c0396;p=interimap.git Add support for SASL-IR (RFC 4959) to save a round-trip in AUTHENTICATE commands. --- diff --git a/lib/Net/IMAP/Sync.pm b/lib/Net/IMAP/Sync.pm index 4a9d431..85ca487 100644 --- a/lib/Net/IMAP/Sync.pm +++ b/lib/Net/IMAP/Sync.pm @@ -347,9 +347,13 @@ sub new($%) { elsif ($mech eq 'PLAIN') { require 'MIME/Base64.pm'; $self->fail("Missing option $_") foreach grep {!defined $self->{$_}} qw/username password/; - $command = "AUTHENTICATE $mech"; my $credentials = MIME::Base64::encode_base64("\x00".$username."\x00".$password, ''); - $callback = sub($) {return $credentials}; + $command = "AUTHENTICATE $mech"; + if ($self->_capable('SASL-IR')) { # RFC 4959 SASL-IR + $command .= " $credentials"; + } else { + $callback = sub($) {return $credentials}; + } } else { $self->fail("Unsupported authentication mechanism: $mech");