#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"
bool stderr_rejection = FALSE;
time_t mtime;
int ret, c;
- string_t *str;
enum mail_error error;
if (getuid() != geteuid() && geteuid() == 0) {
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':
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,
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) {