[Bps-public-commit] r18560 - in Net-IMAP-Server: lib/Net/IMAP/Server/Command

alexmv at bestpractical.com alexmv at bestpractical.com
Tue Feb 24 15:59:20 EST 2009


Author: alexmv
Date: Tue Feb 24 15:59:19 2009
New Revision: 18560

Modified:
   Net-IMAP-Server/   (props changed)
   Net-IMAP-Server/Makefile.PL
   Net-IMAP-Server/lib/Net/IMAP/Server/Command/Create.pm
   Net-IMAP-Server/lib/Net/IMAP/Server/Command/List.pm

Log:
 r42513 at kohr-ah:  chmrr | 2009-02-24 15:58:27 -0500
  * UTF-7 support for mailbox naming


Modified: Net-IMAP-Server/Makefile.PL
==============================================================================
--- Net-IMAP-Server/Makefile.PL	(original)
+++ Net-IMAP-Server/Makefile.PL	Tue Feb 24 15:59:19 2009
@@ -12,6 +12,7 @@
 requires('Email::MIME');
 requires('Email::MIME::ContentType');
 requires('Email::Simple' => 1.999);
+requires('Encode::IMAPUTF7');
 requires('MIME::Base64');
 requires('Net::SSLeay');
 requires('Net::Server::Coro' => 0.3);

Modified: Net-IMAP-Server/lib/Net/IMAP/Server/Command/Create.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server/Command/Create.pm	(original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server/Command/Create.pm	Tue Feb 24 15:59:19 2009
@@ -5,6 +5,9 @@
 
 use base qw/Net::IMAP::Server::Command/;
 
+use Encode;
+use Encode::IMAPUTF7;
+
 sub validate {
     my $self = shift;
 
@@ -14,7 +17,11 @@
     return $self->bad_command("Not enough options") if @options < 1;
     return $self->bad_command("Too many options") if @options > 1;
 
-    my $mailbox = $self->connection->model->lookup( @options );
+    my ($name) = @options;
+    $name = eval { Encode::decode('IMAP-UTF-7', $name) };
+    return $self->bad_command("Invalid UTF-7 encoding") unless defined $name;
+
+    my $mailbox = $self->connection->model->lookup( $name );
     return $self->no_command("Mailbox already exists") if $mailbox;
 
     return 1;
@@ -24,6 +31,7 @@
     my $self = shift;
 
     my($name) = $self->parsed_options;
+    $name = Encode::decode('IMAP-UTF-7',$name);
     my @parts = $self->connection->model->split($name);
 
     my $base = $self->connection->model->root;

Modified: Net-IMAP-Server/lib/Net/IMAP/Server/Command/List.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server/Command/List.pm	(original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server/Command/List.pm	Tue Feb 24 15:59:19 2009
@@ -5,6 +5,9 @@
 
 use base qw/Net::IMAP::Server::Command/;
 
+use Encode;
+use Encode::IMAPUTF7;
+
 sub validate {
     my $self = shift;
 
@@ -47,7 +50,7 @@
 
     my $str = $self->data_out([map {\$_} @props]);
     $str .= q{ "} . $self->connection->model->root->separator . q{" };
-    $str .= q{"} . $node->full_path . q{"};
+    $str .= q{"} . Encode::encode('IMAP-UTF-7',$node->full_path) . q{"};
     $self->tagged_response($str);
 }
 



More information about the Bps-public-commit mailing list