From a9a234f3bc9245c11006506624ec5df65aa88e8e Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Thu, 5 Nov 2009 16:42:28 +0100 Subject: [PATCH] Fixed logging of mailbox names. It logged the converted mUTF7 version in stead of the original UTF8. --- src/lib-sieve/ext-fileinto.c | 14 ++------------ src/lib-sieve/sieve-actions.c | 16 ++++++++++++++-- src/lib-sieve/sieve-actions.h | 3 ++- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/lib-sieve/ext-fileinto.c b/src/lib-sieve/ext-fileinto.c index 5a90a702d..00b414a41 100644 --- a/src/lib-sieve/ext-fileinto.c +++ b/src/lib-sieve/ext-fileinto.c @@ -161,7 +161,7 @@ static int ext_fileinto_operation_execute (const struct sieve_runtime_env *renv, sieve_size_t *address) { struct sieve_side_effects_list *slist = NULL; - string_t *folder, *folder_utf7; + string_t *folder; const char *mailbox; unsigned int source_line; int ret = 0; @@ -194,19 +194,9 @@ static int ext_fileinto_operation_execute mailbox = str_sanitize(str_c(folder), 64); sieve_runtime_trace(renv, "FILEINTO action (\"%s\")", mailbox); - /* Convert utf-8 folder name to utf-7 - * FIXME: perform this at compile time when possible. - */ - folder_utf7 = t_str_new(256); - if ( imap_utf8_to_utf7(str_c(folder), folder_utf7) < 0 ) { - sieve_runtime_error - (renv, sieve_error_script_location(renv->script, source_line), - "mailbox name not utf-8: %s", mailbox); - } - /* Add action to result */ ret = sieve_act_store_add_to_result - (renv, slist, str_c(folder_utf7), source_line); + (renv, slist, str_c(folder), source_line); return ( ret >= 0 ); } diff --git a/src/lib-sieve/sieve-actions.c b/src/lib-sieve/sieve-actions.c index c15c7e0ae..e6b96d4c0 100644 --- a/src/lib-sieve/sieve-actions.c +++ b/src/lib-sieve/sieve-actions.c @@ -2,10 +2,12 @@ */ #include "lib.h" +#include "str.h" #include "strfuncs.h" #include "str-sanitize.h" #include "mail-storage.h" #include "mail-namespace.h" +#include "imap-utf7.h" #include "sieve-code.h" #include "sieve-extensions.h" @@ -271,15 +273,25 @@ static struct mailbox *act_store_mailbox_open enum mailbox_flags flags = MAILBOX_FLAG_KEEP_RECENT | MAILBOX_FLAG_SAVEONLY | MAILBOX_FLAG_POST_SESSION; + string_t *mailbox_mutf7; struct mailbox *box; enum mail_error error; + /* Deliveries to INBOX must always succeed, regardless of ACLs */ if (strcasecmp(*mailbox, "INBOX") == 0) { - /* Deliveries to INBOX must always succeed, regardless of ACLs */ flags |= MAILBOX_FLAG_IGNORE_ACLS; } - *folder_r = *mailbox; + /* Convert utf-8 folder name to utf-7 + */ + mailbox_mutf7 = t_str_new(256); + if ( imap_utf8_to_utf7(*mailbox, mailbox_mutf7) < 0 ) { + /* FIXME: check utf-8 validity at compiletime/runtime */ + sieve_result_error(aenv, "mailbox name not utf-8: %s", *mailbox); + return NULL; + } + + *folder_r = str_c(mailbox_mutf7); *ns_r = mail_namespace_find(aenv->scriptenv->namespaces, folder_r); if ( *ns_r == NULL) { *storage = NULL; diff --git a/src/lib-sieve/sieve-actions.h b/src/lib-sieve/sieve-actions.h index a8fa62e46..48e6eecf5 100644 --- a/src/lib-sieve/sieve-actions.h +++ b/src/lib-sieve/sieve-actions.h @@ -191,7 +191,7 @@ extern const struct sieve_action_def act_discard; */ struct act_store_context { - /* Folder name represented in modified utf-7 */ + /* Folder name represented in utf-8 */ const char *mailbox; }; @@ -203,6 +203,7 @@ struct act_store_transaction { struct mail *dest_mail; const char *folder; + const char *folder_mutf7; const char *error; enum mail_error error_code; -- GitLab