]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail_deliver_save() now takes mailbox name as UTF-8 and internally converts to mUTF-7.
authorTimo Sirainen <tss@iki.fi>
Wed, 11 Nov 2009 17:40:50 +0000 (12:40 -0500)
committerTimo Sirainen <tss@iki.fi>
Wed, 11 Nov 2009 17:40:50 +0000 (12:40 -0500)
--HG--
branch : HEAD

src/lda/main.c
src/lib-lda/mail-deliver.c

index a24e9410efcf85b30b94210121163581304f550c..938da783d96e61e679d7f1f2696887e94ac05cf7 100644 (file)
@@ -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':
index b8b5167bca3edc94aa8a2f0f65015952dfe8c492..471a04dd38d812c0a1aaf06cc8305f4735472f0e 100644 (file)
@@ -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) {