Subject: | Patch for SSL support |
This patch will add SSL support to IMAPClient. It needs IO::Socket::SSL. You may want to make it optional in the same way as CRAM-MD5.
Also changed login, because passwords were logged otherwise (because of multi-line string).
--- IMAPClient.pm 2003-07-02 19:28:54.000000000 +0200
+++ /usr/share/perl5/Mail/IMAPClient.pm 2004-12-30 13:08:10.000000000 +0100
@@ -8,6 +8,7 @@
use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
use Socket();
use IO::Socket();
+use IO::Socket::SSL();
use IO::Select();
use IO::File();
use Carp qw(carp);
@@ -114,6 +115,7 @@
Authmechanism Authcallback Ranges
Readmethod Showcredentials
Prewritemethod
+ Ssl
)
) {
no strict 'refs';
@@ -245,13 +247,15 @@
and $IO::Socket::INET::VERSION eq '1.25'
and !$self->Port;
%$self = (%$self, @_);
- my $sock = IO::Socket::INET->new(
+ my $sock = ($self->Ssl ? IO::Socket::SSL->new : IO::Socket::INET->new);
+ my $dp = ($self->Ssl ? 'imaps(993)' : 'imap(143)');
+ $sock->configure({
PeerAddr => $self->Server ,
- PeerPort => $self->Port||'imap(143)' ,
+ PeerPort => $self->Port||$dp ,
Proto => 'tcp' ,
Timeout => $self->Timeout||0 ,
Debug => $self->Debug ,
- ) ;
+ }) ;
unless ( defined($sock) ) {
@@ -302,9 +306,10 @@
my $id = $self->User;
my $has_quotes = $id =~ /^".*"$/ ? 1 : 0;
- my $string = "Login " . ( $has_quotes ? $id : qq("$id") ) . " " .
- "{" . length($self->Password) .
- "}\r\n".$self->Password."\r\n";
+ #my $string = "Login " . ( $has_quotes ? $id : qq("$id") ) . " " .
+ # "{" . length($self->Password) .
+ # "}\r\n".$self->Password."\r\n";
+ my $string = "Login " . ( $has_quotes ? $id : qq("$id") ) . " " . $self->Password . "\r\n";
$self->_imap_command($string)
and $self->State(Authenticated);
# $self->folders and $self->separator unless $self->NoAutoList;
@@ -1628,7 +1633,7 @@
return undef;
}
# successfully wrote to other end, keep going...
- $count += $ret;
+ $count += $ret if defined($ret);
LINES: while ( $iBuffer =~ s/^(.*?\x0d?\x0a)// ) {
my $current_line = $1;
@@ -2167,8 +2172,8 @@
(?:"[^"]*"|NIL)\s+ # "delimiter" or NIL
(?:"([^"]*)"|(.*))\x0d\x0a$ # Name or "Folder name"
/ix;
- $folders[-1] = '"' . $folders[-1] . '"'
- if $1 and !$self->exists($folders[-1]) ;
+ #$folders[-1] = '"' . $folders[-1] . '"'
+ # if $1 and !$self->exists($folders[-1]) ;
# $self->_debug("folders: line $list[$m]: 1=$1 and 2=$2\n");
}