]> git.g-eek.se Git - interimap.git/commitdiff
Add support for SASL-IR (RFC 4959) to save a round-trip in AUTHENTICATE commands.
authorGuilhem Moulin <guilhem@fripost.org>
Sun, 9 Aug 2015 18:38:30 +0000 (20:38 +0200)
committerGuilhem Moulin <guilhem@fripost.org>
Sun, 9 Aug 2015 18:38:30 +0000 (20:38 +0200)
lib/Net/IMAP/Sync.pm

index 4a9d431f35b43933a867c65782db70181fbcfdde..85ca48733bf39a91c8bcac25491a8369cb2839d9 100644 (file)
@@ -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");