From b1985240f59a22b27824c9fdcb79998a1c7c0396 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 9 Aug 2015 20:38:30 +0200 Subject: Add support for SASL-IR (RFC 4959) to save a round-trip in AUTHENTICATE commands. --- lib/Net/IMAP/Sync.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/Net') 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"); -- cgit v1.2.3