dovecot-2.0-sslstream: mail_deliver_save() now takes mailbox nam...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 13 02:56:20 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0-sslstream/rev/05d94015d0ef
changeset: 10309:05d94015d0ef
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 11 12:40:50 2009 -0500
description:
mail_deliver_save() now takes mailbox name as UTF-8 and internally converts to mUTF-7.

diffstat:

2 files changed, 10 insertions(+), 12 deletions(-)
src/lda/main.c             |    8 +++-----
src/lib-lda/mail-deliver.c |   14 +++++++-------

diffs (69 lines):

diff -r c21543e87190 -r 05d94015d0ef src/lda/main.c
--- a/src/lda/main.c	Tue Nov 10 20:01:19 2009 -0500
+++ b/src/lda/main.c	Wed Nov 11 12:40:50 2009 -0500
@@ -13,6 +13,7 @@
 #include "str.h"
 #include "str-sanitize.h"
 #include "strescape.h"
+#include "unichar.h"
 #include "rfc822-parser.h"
 #include "message-address.h"
 #include "imap-utf7.h"
@@ -261,7 +262,6 @@ int main(int argc, char *argv[])
 	bool stderr_rejection = FALSE;
 	time_t mtime;
 	int ret, c;
-	string_t *str;
 	enum mail_error error;
 
 	if (getuid() != geteuid() && geteuid() == 0) {
@@ -319,13 +319,11 @@ int main(int argc, char *argv[])
 			   Ignore -m "". This allows doing -m ${extension}
 			   in Postfix to handle user+mailbox */
 			if (*optarg != '\0') T_BEGIN {
-				str = t_str_new(256);
-				if (imap_utf8_to_utf7(optarg, str) < 0) {
+				if (uni_utf8_str_is_valid(optarg) < 0) {
 					i_fatal("Mailbox name not UTF-8: %s",
 						optarg);
 				}
-				ctx.dest_mailbox_name =
-					p_strdup(ctx.pool, str_c(str));
+				ctx.dest_mailbox_name = optarg;
 			} T_END;
 			break;
 		case 'p':
diff -r c21543e87190 -r 05d94015d0ef src/lib-lda/mail-deliver.c
--- a/src/lib-lda/mail-deliver.c	Tue Nov 10 20:01:19 2009 -0500
+++ b/src/lib-lda/mail-deliver.c	Wed Nov 11 12:40:50 2009 -0500
@@ -138,15 +138,14 @@ mailbox_open_or_create_synced(struct mai
 	return box;
 }
 
-static const char *mailbox_name_get_printable(const char *mailbox_mutf7)
+static const char *mailbox_name_to_mutf7(const char *mailbox_utf8)
 {
 	string_t *str = t_str_new(128);
 
-	if (imap_utf7_to_utf8(mailbox_mutf7, str) < 0) {
-		str_truncate(str, 0);
-		str_append(str, mailbox_mutf7);
-	}
-	return str_sanitize(str_c(str), 80);
+	if (imap_utf8_to_utf7(mailbox_utf8, str) < 0)
+		return mailbox_utf8;
+	else
+		return str_c(str);
 }
 
 int mail_deliver_save(struct mail_deliver_context *ctx, const char *mailbox,
@@ -170,7 +169,8 @@ int mail_deliver_save(struct mail_delive
 	if (default_save)
 		ctx->tried_default_save = TRUE;
 
-	mailbox_name = mailbox_name_get_printable(mailbox);
+	mailbox_name = str_sanitize(mailbox, 80);
+	mailbox = mailbox_name_to_mutf7(mailbox);
 	box = mailbox_open_or_create_synced(ctx, mailbox, &ns, &errstr);
 	if (box == NULL) {
 		if (ns == NULL) {


More information about the dovecot-cvs mailing list