Please apply patches for dovecot-metadata-plugin v14.1. dovecot-metadata-plugin-value_nil - fix plugin crach if entry->value == NULL (strlen(NULL) - segfault). 2. dovecot-metadata-plugin-utf7_support - add support metadata for UTF8 mailfolder.
-- Sidlyarenko Sergey https://github.com/lefoyer
diff -rNu dovecot-metadata-plugin-2a17386d4dbc/src/metadata-entry.c dovecot-metadata-plugin-new/src/metadata-entry.c --- dovecot-metadata-plugin-2a17386d4dbc/src/metadata-entry.c 2013-05-14 12:13:53.000000000 +0400 +++ dovecot-metadata-plugin-new/src/metadata-entry.c 2013-07-14 03:01:37.709320981 +0400 @@ -151,7 +151,7 @@ if (entry == NULL) return NULL; - return entry->value; + return entry->value == NULL ? "NIL" : entry->value; } enum metadata_entry_subject
diff -rNu dovecot-metadata-plugin-2a17386d4dbc/src/imap-metadata-plugin.c dovecot-metadata-plugin-new/src/imap-metadata-plugin.c --- dovecot-metadata-plugin-2a17386d4dbc/src/imap-metadata-plugin.c 2013-05-14 12:13:53.000000000 +0400 +++ dovecot-metadata-plugin-new/src/imap-metadata-plugin.c 2013-07-14 21:57:07.653321000 +0400 @@ -34,6 +34,7 @@ #include "metadata-entry.h" #include "metadata-backend.h" #include "metadata-mail-user-module-private.h" +#include "imap-utf7.h" /* The IMAP Metadata plugin is an implementation of RFC 5464 */ @@ -332,12 +333,19 @@ } const char *mailbox_name = mailbox_get_vname(box); + const char *mailbox_name_utf7 = NULL; string_t *str = t_str_new(128); str_append(str, "* METADATA "); #if DOVECOT_PREREQ(2,2) - imap_append_string(str, mailbox_name); -#else - imap_quote_append_string(str, mailbox_name, false); + if (t_imap_utf8_to_utf7(mailbox_name, &mailbox_name_utf7) == 0) + imap_append_string(str, mailbox_name_utf7); + else + imap_append_string(str, mailbox_name); +#else + if (t_imap_utf8_to_utf7(mailbox_name, &mailbox_name_utf7) == 0) + imap_quote_append_string(str, mailbox_name_utf7, false); + else + imap_quote_append_string(str, mailbox_name, false); #endif str_append(str, " ("); #if DOVECOT_PREREQ(2,2) @@ -368,12 +376,19 @@ int num_entries = 0; const char *mailbox_name = mailbox_get_vname(box); + const char *mailbox_name_utf7 = NULL; string_t *str = t_str_new(128); str_append(str, "* METADATA "); #if DOVECOT_PREREQ(2,2) - imap_append_string(str, mailbox_name); -#else - imap_quote_append_string(str, mailbox_name, false); + if (t_imap_utf8_to_utf7(mailbox_name, &mailbox_name_utf7)) + imap_append_string(str, mailbox_name_utf7); + else + imap_append_string(str, mailbox_name); +#else + if (t_imap_utf8_to_utf7(mailbox_name, &mailbox_name_utf7)) + imap_quote_append_string(str, mailbox_name_utf7, false); + else + imap_quote_append_string(str, mailbox_name, false); #endif str_append(str, " ("); @@ -503,6 +518,12 @@ return true; } + if (imap_utf7_is_valid(mailbox_name)) { + string_t *mailbox_name_utf8 = t_str_new(strlen(mailbox_name)); + if (imap_utf7_to_utf8(mailbox_name, mailbox_name_utf8) == 0) + mailbox_name = str_c(mailbox_name_utf8); + } + const char **entry_names = NULL; if (!imap_arg_get_astringlist(&args[1], &entry_names)) { client_send_command_error(cmd, "Cannot read entries - string or list of strings expected. (RFC 5464 Section 4.2)"); @@ -727,6 +748,12 @@ return true; } + if (imap_utf7_is_valid(mailbox_name)) { + string_t *mailbox_name_utf8 = t_str_new(strlen(mailbox_name)); + if (imap_utf7_to_utf8(mailbox_name, mailbox_name_utf8) == 0) + mailbox_name = str_c(mailbox_name_utf8); + } + struct mailbox *box = NULL; /* empty name -> box=NULL -> server scope */ if (*mailbox_name != '\0') {