Mercurial > dovecot > core-2.2
changeset 10308:05d94015d0ef HEAD
mail_deliver_save() now takes mailbox name as UTF-8 and internally converts to mUTF-7.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 11 Nov 2009 12:40:50 -0500 |
parents | c21543e87190 |
children | 49d92c3fa17a |
files | src/lda/main.c src/lib-lda/mail-deliver.c |
diffstat | 2 files changed, 10 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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 @@ 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':
--- 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 @@ 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 @@ 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) {