[Bps-public-commit] Net-IMAP-Server branch, master, updated. 1.31-6-g25ca47e
Alex Vandiver
alexmv at bestpractical.com
Fri Apr 6 00:57:18 EDT 2012
The branch, master has been updated
via 25ca47e117e10948d639bc37dcb48c6c5681b0e8 (commit)
via ecedc280aa6f0c1431390e1f5def8f6387d06bbb (commit)
via 1dfea20e5f1034ee4bbce3c743da0b91b9eaef44 (commit)
via 3acd56b76f7a3d5bcfcf75c361acddcfb2a0da16 (commit)
via 38943296dcd37cdab343bb8c377bf994b3bed68d (commit)
via 1c61b2981f0e2915e2e7b46e6fe121980bd28105 (commit)
from 3e4e1d4edfb3dde6bfd96ed22e12d4875da451e7 (commit)
Summary of changes:
Changes | 8 ++++++
MANIFEST | 1 +
Makefile.PL | 14 +++++-----
README | 36 +++++++++++++++------------
lib/Net/IMAP/Server.pm | 2 +-
lib/Net/IMAP/Server/Command/Authenticate.pm | 20 ++++++---------
lib/Net/IMAP/Server/Connection.pm | 6 +---
7 files changed, 47 insertions(+), 40 deletions(-)
- Log -----------------------------------------------------------------
commit 1c61b2981f0e2915e2e7b46e6fe121980bd28105
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 6 00:04:28 2012 -0400
Minor toolchain fixes and tweaks
diff --git a/MANIFEST b/MANIFEST
index 53151d1..a791adb 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -8,6 +8,7 @@ inc/Module/Install/Can.pm
inc/Module/Install/Fetch.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
+inc/Module/Install/ReadmeFromPod.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/Net/IMAP/Server.pm
diff --git a/Makefile.PL b/Makefile.PL
index 751ed81..0dd1ca3 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,11 +1,13 @@
use inc::Module::Install;
-name ('Net-IMAP-Server');
-author ('Alex Vandiver <alexmv at mit.edu>');
-version_from ('lib/Net/IMAP/Server.pm');
+name('Net-IMAP-Server');
+author('Alex Vandiver <alexmv at bestpractical.com>');
+version_from('lib/Net/IMAP/Server.pm');
abstract_from('lib/Net/IMAP/Server.pm');
-repository("http://github.com/bestpractical/net-imap-server/");
+repository('http://github.com/bestpractical/net-imap-server/');
license('perl');
+readme_from('lib/Net/IMAP/Server.pm');
+sign;
requires('Class::Accessor');
requires('Coro');
@@ -26,6 +28,4 @@ requires('UNIVERSAL::require');
test_requires('IO::Socket::SSL');
-sign;
-
WriteAll;
diff --git a/README b/README
index f53b7a1..e1074c9 100644
--- a/README
+++ b/README
@@ -172,48 +172,52 @@ Object model
| Server |
| |
+1-----2---------------------------------------+
- # ' ^ ^ ^ ^
- # ' | | | |
+ # | ^ ^ ^ ^
+ # | | | | |
# v | | | |
# +--------1-------+ | +------1------+ |
###>| Connection |<------2 Command | |
# +--4-----3------2+ | +-------------+ |
- /-#------/ | \--------------\ |
+ ,-#------' | `--------------. |
| # v | v |
| # +----------------+ | +-------------+ |
| # | Model 2------>| Auth | |
| # +--------1-------+ | +-------------+ |
- | # \---------------------------------\
+ | # `---------------------------------.
| # | | |
- | # /---/ /---/ |
+ | # ,---' ,---' |
| # +--------------1-+ +-----------1-+ |
| ###>| Connection |<------2 Command | |
| +--4-5---3------2+ +-------------+ |
- | /------/ * | \--------------\ |
+ | ,------' * | `--------------. |
| | ******** v v |
| | * +----------------+ +-------------+ |
| | * | Model 2------>| Auth | |
| | * +--------1-------+ +-------------+ |
| | * | |
- | | * | /------------------------------/
+ | | * | ,------------------------------'
| | * | | ^ SERVER
- |.|.*..........|..|................................
+ .|.|.*..........|..|................................
| | * | | v MODEL
| | * v v
- | \-*---->+-------------+<------------\
- \---*---->| Mailbox |<----------\ |
- * +-1------2-3--+<----\ | |
+ | '-*---->+-------------+<------------.
+ '---*---->| Mailbox |<----------. |
+ * +-1------2-3--+<----. | |
* @ ^ $ % | | |
- * @ | $$%$>+-----1---+ | |
+ * @ | $$$$>+-----1---+ | |
+ * @ | $ % | | | |
* @ | $ %%>| Message | | |
- ********@***|****%*>+---------+ | |
+ * @ | $ % | | | |
+ ********@***|******>+---------+ | |
* @ | $ % | |
- * @ | $$%$>+---------+ | |
- * @ | %%>| Message 1-/ |
+ * @ | $$$$>+---------+ | |
+ * @ | % | | | |
+ * @ | %%>| Message 1-' |
+ * @ | | | |
********@***|******>+---------+ |
* @ | |
* @ | +---------+ |
- * @ | | Message 1---/
+ * @ | | Message 1---'
********@***|******>+---------+
@ |
@ +4----------+
commit 38943296dcd37cdab343bb8c377bf994b3bed68d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 6 00:09:08 2012 -0400
Always trim newlines from commands, even continuations
Previously, Net::IMAP::Server::Connection->parse_command trimmed
trailing newlines, meaning that parsed options would not have trailing
newlines. However, continuation commands, such as for AUTHENTICATE,
were passed the unmodified input, including trailing \r\n.
As the \r\n is a property of the communication channel, and should not
be used for information transfer, remove them for consistency. This
does not impact SASL implementations, however, as they are passed the
output of decode_base64, which is agnostic to the presence of trailing
whitespace. Only third-party commands which use ->pending are affected
by this change.
diff --git a/lib/Net/IMAP/Server/Command/Authenticate.pm b/lib/Net/IMAP/Server/Command/Authenticate.pm
index 53a3537..a5d380a 100644
--- a/lib/Net/IMAP/Server/Command/Authenticate.pm
+++ b/lib/Net/IMAP/Server/Command/Authenticate.pm
@@ -52,7 +52,7 @@ sub continue {
$self->connection->pending(undef);
return $self->bad_command("Login cancelled")
- if not defined $line or $line =~ /^\*[\r\n]+$/;
+ if not defined $line or $line =~ /^\*$/;
my $fail = 0;
{
diff --git a/lib/Net/IMAP/Server/Connection.pm b/lib/Net/IMAP/Server/Connection.pm
index 141c25d..eb6823e 100644
--- a/lib/Net/IMAP/Server/Connection.pm
+++ b/lib/Net/IMAP/Server/Connection.pm
@@ -259,10 +259,9 @@ sub handle_command {
my $self = shift;
my $content = shift;
- my $output = $content;
- $output =~ s/[\r\n]+$//;
+ $content =~ s/[\r\n]+$//;
$self->log( 4,
- "C(@{[$self]},@{[$self->auth ? $self->auth->user : '???']},@{[$self->is_selected ? $self->selected->full_path : 'unselected']}): $output"
+ "C(@{[$self]},@{[$self->auth ? $self->auth->user : '???']},@{[$self->is_selected ? $self->selected->full_path : 'unselected']}): $content"
);
if ( $self->pending ) {
@@ -361,7 +360,6 @@ undef if parsing fails for some reason.
sub parse_command {
my $self = shift;
my $line = shift;
- $line =~ s/[\r\n]+$//;
my $TAG = qr/([^\(\)\{ \*\%"\\\+}]+)/;
unless ( $line =~ /^$TAG\s+(\w+)(?:\s+(.+?))?$/ ) {
if ( $line !~ /^$TAG\s+/ ) {
commit 3acd56b76f7a3d5bcfcf75c361acddcfb2a0da16
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 6 00:14:08 2012 -0400
Remove an erroneous trailing \n in SASL responses
encode_base64 adds a tailing \n to its output, which is unwanted in this
context, as ->out appends the \r\n mandated by IMAP specification.
Prevent the erroneous extra \n by passing the empty string as
encode_base64's EOL parameter.
diff --git a/lib/Net/IMAP/Server/Command/Authenticate.pm b/lib/Net/IMAP/Server/Command/Authenticate.pm
index a5d380a..378771d 100644
--- a/lib/Net/IMAP/Server/Command/Authenticate.pm
+++ b/lib/Net/IMAP/Server/Command/Authenticate.pm
@@ -66,7 +66,7 @@ sub continue {
my $response = $self->sasl->($line);
if ( ref $response ) {
$self->connection->pending(sub{$self->continue(@_)});
- $self->out( "+ " . encode_base64($$response) );
+ $self->out( "+ " . encode_base64($$response, "") );
} elsif (not $response) {
$self->no_command("Invalid login");
} elsif ($response < 0) {
commit 1dfea20e5f1034ee4bbce3c743da0b91b9eaef44
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 6 00:14:54 2012 -0400
Detect invalid base64 using a round-trip test, rather than warnings
MIME::Base64 version 3.11 removed the warning that was being trapped to
detect invalid base64 data. Rather than rely on the warning, instead
attempt to round-trip the data to ensure that the client encoded it
cleanly.
diff --git a/Makefile.PL b/Makefile.PL
index 0dd1ca3..0bdb869 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -19,7 +19,7 @@ requires('Email::MIME' => 1.862);
requires('Email::MIME::ContentType');
requires('Email::Simple' => 1.999);
requires('Encode::IMAPUTF7');
-requires('MIME::Base64');
+requires('MIME::Base64' => 3.11);
requires('Net::SSLeay');
requires('Net::Server::Coro' => 0.6);
requires('Regexp::Common');
diff --git a/lib/Net/IMAP/Server/Command/Authenticate.pm b/lib/Net/IMAP/Server/Command/Authenticate.pm
index 378771d..146eae4 100644
--- a/lib/Net/IMAP/Server/Command/Authenticate.pm
+++ b/lib/Net/IMAP/Server/Command/Authenticate.pm
@@ -54,16 +54,11 @@ sub continue {
return $self->bad_command("Login cancelled")
if not defined $line or $line =~ /^\*$/;
- my $fail = 0;
- {
- # Trap and fail on "Premature end of base64 data", etc..
- local $^W = 1;
- local $SIG{__WARN__} = sub {$_[0] =~ /base64/i and $fail++};
- $line = decode_base64($line);
- }
- return $self->bad_command("Invalid base64") if $fail;
+ my $decoded = decode_base64($line);
+ return $self->bad_command("Invalid base64")
+ if encode_base64($decoded, "") ne $line;
- my $response = $self->sasl->($line);
+ my $response = $self->sasl->($decoded);
if ( ref $response ) {
$self->connection->pending(sub{$self->continue(@_)});
$self->out( "+ " . encode_base64($$response, "") );
commit ecedc280aa6f0c1431390e1f5def8f6387d06bbb
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 6 00:17:02 2012 -0400
Ensure that all SASL mechanisms are mapped to valid method names
SASL mechanisms are defined, per RFC 4422, as:
sasl-mech = 1*20mech-char
mech-char = UPPER-ALPHA / DIGIT / HYPHEN / UNDERSCORE
; mech-char is restricted to A-Z (uppercase only), 0-9, -, and _
; from ASCII character set.
UPPER-ALPHA = %x41-5A ; A-Z (uppercase only)
DIGIT = %x30-39 ; 0-9
HYPHEN = %x2D ; hyphen (-)
UNDERSCORE = %x5F ; underscore (_)
Of this set, only - is invalid in a perl method name; remap it to _.
While this could conceivably cause conflicts between SOME-NAME and
SOME_NAME, such a naming similarity is extremely unlikely to ever occur
in IANA's curated list of mechanisms.
diff --git a/lib/Net/IMAP/Server/Command/Authenticate.pm b/lib/Net/IMAP/Server/Command/Authenticate.pm
index 146eae4..c8cc006 100644
--- a/lib/Net/IMAP/Server/Command/Authenticate.pm
+++ b/lib/Net/IMAP/Server/Command/Authenticate.pm
@@ -35,6 +35,7 @@ sub run {
my $auth = $self->server->auth_class->new;
if ( grep {uc $type eq uc $_} $auth->sasl_provides ) {
$type = lc $type;
+ $type =~ s/\W/_/g;
my $function = "sasl_$type";
$self->sasl( $auth->$function() );
$self->pending_auth($auth);
commit 25ca47e117e10948d639bc37dcb48c6c5681b0e8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 6 00:50:42 2012 -0400
Version 1.32 releng
diff --git a/Changes b/Changes
index 1bbcdbb..5c71514 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,13 @@
Revision history for Net-IMAP-Server
+1.32 Fri Apr 06 00:45:17 2012
+ * Trim newlines passed to all commands, including continuation
+ lines
+ * Remove erroneous extra \n on server SASL responses
+ * Bump MIME::Base64 dependency, and adjust bad mime encoding
+ techniques to compensate
+ * Better mapping of SASL mechanism names to method names
+
1.31 Sun Apr 01 01:18:17 2012
* Add test dependency on IO::Socket::SSL
* Minor ASCII art updates
diff --git a/lib/Net/IMAP/Server.pm b/lib/Net/IMAP/Server.pm
index f5e0903..b5bbbfe 100644
--- a/lib/Net/IMAP/Server.pm
+++ b/lib/Net/IMAP/Server.pm
@@ -8,7 +8,7 @@ use base qw/Net::Server::Coro Class::Accessor/;
use UNIVERSAL::require;
use Coro;
-our $VERSION = '1.31';
+our $VERSION = '1.32';
=head1 NAME
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list