From: Timo Sirainen Date: Wed, 11 Nov 2009 17:40:50 +0000 (-0500) Subject: mail_deliver_save() now takes mailbox name as UTF-8 and internally converts to mUTF-7. X-Git-Tag: 2.0.beta1~171 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f185133819c115c8cbc1c7e96804f237e23d255c;p=thirdparty%2Fdovecot%2Fcore.git mail_deliver_save() now takes mailbox name as UTF-8 and internally converts to mUTF-7. --HG-- branch : HEAD --- diff --git a/src/lda/main.c b/src/lda/main.c index a24e9410ef..938da783d9 100644 --- a/src/lda/main.c +++ b/src/lda/main.c @@ -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 --git a/src/lib-lda/mail-deliver.c b/src/lib-lda/mail-deliver.c index b8b5167bca..471a04dd38 100644 --- a/src/lib-lda/mail-deliver.c +++ b/src/lib-lda/mail-deliver.c @@ -138,15 +138,14 @@ mailbox_open_or_create_synced(struct mail_deliver_context *ctx, 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_deliver_context *ctx, const char *mailbox, 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) {