]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Rename mailbox_list_settings.broken_char to vname_escape_char
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 13 Jan 2021 16:50:38 +0000 (18:50 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 3 Feb 2021 09:04:22 +0000 (09:04 +0000)
This clarifies that it's only used in vnames.

src/doveadm/doveadm-dsync.c
src/lib-storage/index/imapc/imapc-list.c
src/lib-storage/index/imapc/imapc-storage.h
src/lib-storage/mailbox-list.c
src/lib-storage/mailbox-list.h

index f0494bd6f34e194b275cb95e2aa71fa398d7c264..dcdfe4d677814650c42e00af507fb070a4700370 100644 (file)
 
 #define DSYNC_COMMON_GETOPT_ARGS "+1a:dDEfg:I:l:m:n:NO:Pr:Rs:t:e:T:Ux:"
 #define DSYNC_REMOTE_CMD_EXIT_WAIT_SECS 30
-/* The broken_char is mainly set to get a proper error message when trying to
-   convert a mailbox with a name that can't be used properly translated between
-   vname/storage_name and would otherwise be mixed up with a normal "mailbox
-   doesn't exist" error message. This could be any control character, since
-   none of them are allowed to be created in regular mailbox names. */
-#define DSYNC_LIST_BROKEN_CHAR '\003'
+/* The vname_escape_char is mainly set to get a proper error message when
+   trying to convert a mailbox with a name that can't be used properly
+   translated between vname/storage_name and would otherwise be mixed up with a
+   normal "mailbox doesn't exist" error message. This could be any control
+   character, since none of them are allowed to be created in regular mailbox
+   names. */
+#define DSYNC_LIST_VNAME_ESCAPE_CHAR '\003'
 
 #define DSYNC_DEFAULT_IO_STREAM_TIMEOUT_SECS (60*10)
 
@@ -327,8 +328,8 @@ static void doveadm_user_init_dsync(struct mail_user *user)
 
        user->dsyncing = TRUE;
        for (ns = user->namespaces; ns != NULL; ns = ns->next) {
-               if (ns->list->set.broken_char == '\0')
-                       ns->list->set.broken_char = DSYNC_LIST_BROKEN_CHAR;
+               if (ns->list->set.vname_escape_char == '\0')
+                       ns->list->set.vname_escape_char = DSYNC_LIST_VNAME_ESCAPE_CHAR;
        }
 }
 
index d2409d46b3617a35859029e55e9b44ed5584c9f0..c2f3c478ae54a0bad715394eac641cf0ebafd5da 100644 (file)
@@ -395,7 +395,7 @@ static struct mailbox_list *imapc_list_get_fs(struct imapc_mailbox_list *list)
                list_set.root_dir = dir;
                list_set.storage_name_escape_char =
                        IMAPC_LIST_STORAGE_NAME_ESCAPE_CHAR;
-               list_set.broken_char = IMAPC_LIST_BROKEN_CHAR;
+               list_set.vname_escape_char = IMAPC_LIST_VNAME_ESCAPE_CHAR;
 
                if (mailbox_list_create(list_set.layout, list->list.ns,
                                        &list_set, MAILBOX_LIST_FLAG_SECONDARY,
index c5cf8e276986139f155dbb9d392105a980ba5e22..91f4c4b2b8a1d4055a25c72cc13745f8b14f9029 100644 (file)
@@ -7,7 +7,7 @@
 
 #define IMAPC_STORAGE_NAME "imapc"
 #define IMAPC_LIST_STORAGE_NAME_ESCAPE_CHAR '%'
-#define IMAPC_LIST_BROKEN_CHAR '~'
+#define IMAPC_LIST_VNAME_ESCAPE_CHAR '~'
 
 struct imap_arg;
 struct imapc_untagged_reply;
index 5cbb27c63543a1bb8db1eba3d032bf92d91dffd8..72936bd412642f19672c89891991c0a642cf76eb 100644 (file)
@@ -200,7 +200,7 @@ int mailbox_list_create(const char *driver, struct mail_namespace *ns,
                        p_strconcat(list->pool, set->mailbox_dir_name, "/", NULL);
        }
        list->set.storage_name_escape_char = set->storage_name_escape_char;
-       list->set.broken_char = set->broken_char;
+       list->set.vname_escape_char = set->vname_escape_char;
        list->set.utf8 = set->utf8;
 
        if (list->v.init != NULL) {
@@ -365,7 +365,7 @@ mailbox_list_settings_parse_full(struct mail_user *user, const char *data,
                                *error_r = "BROKENCHAR value must be a single character";
                                return -1;
                        }
-                       set_r->broken_char = value[0];
+                       set_r->vname_escape_char = value[0];
                        continue;
                } else if (strcmp(key, "ITERINDEX") == 0) {
                        set_r->iter_from_index_dir = TRUE;
@@ -531,12 +531,12 @@ mailbox_list_unescape_broken_chars(struct mailbox_list *list, char *name)
        char *src, *dest;
        unsigned char chr;
 
-       if ((src = strchr(name, list->set.broken_char)) == NULL)
+       if ((src = strchr(name, list->set.vname_escape_char)) == NULL)
                return 0;
        dest = src;
 
        while (*src != '\0') {
-               if (*src == list->set.broken_char) {
+               if (*src == list->set.vname_escape_char) {
                        if (src[1] >= '0' && src[1] <= '9')
                                chr = (src[1]-'0') * 0x10;
                        else if (src[1] >= 'a' && src[1] <= 'f')
@@ -631,15 +631,15 @@ const char *mailbox_list_default_get_storage_name(struct mailbox_list *list,
                }
 
                ret = mailbox_list_convert_sep(storage_name, ns_sep, list_sep);
-       } else if (list->set.broken_char == '\0' ||
-                  strchr(storage_name, list->set.broken_char) == NULL) {
+       } else if (list->set.vname_escape_char == '\0' ||
+                  strchr(storage_name, list->set.vname_escape_char) == NULL) {
                /* no need to convert broken chars */
                return storage_name;
        } else {
                ret = p_strdup(unsafe_data_stack_pool, storage_name);
        }
 
-       if (list->set.broken_char != '\0') {
+       if (list->set.vname_escape_char != '\0') {
                if (mailbox_list_unescape_broken_chars(list, ret) < 0) {
                        ret = mailbox_list_convert_sep(storage_name,
                                                       ns_sep, list_sep);
@@ -705,13 +705,13 @@ mailbox_list_escape_broken_chars(struct mailbox_list *list, string_t *str)
        unsigned int i;
        char buf[3];
 
-       if (strchr(str_c(str), list->set.broken_char) == NULL)
+       if (strchr(str_c(str), list->set.vname_escape_char) == NULL)
                return;
 
        for (i = 0; i < str_len(str); i++) {
-               if (str_c(str)[i] == list->set.broken_char) {
+               if (str_c(str)[i] == list->set.vname_escape_char) {
                        i_snprintf(buf, sizeof(buf), "%02x",
-                                  list->set.broken_char);
+                                  list->set.vname_escape_char);
                        str_insert(str, i+1, buf);
                        i += 2;
                }
@@ -725,7 +725,7 @@ mailbox_list_escape_broken_name(struct mailbox_list *list,
        str_truncate(str, 0);
        for (; *vname != '\0'; vname++) {
                if (*vname == '&' || (unsigned char)*vname >= 0x80) {
-                       str_printfa(str, "%c%02x", list->set.broken_char,
+                       str_printfa(str, "%c%02x", list->set.vname_escape_char,
                                    (unsigned char)*vname);
                } else {
                        str_append_c(str, *vname);
@@ -768,10 +768,10 @@ const char *mailbox_list_default_get_vname(struct mailbox_list *list,
                /* mUTF-7 -> UTF-8 conversion */
                string_t *str = t_str_new(strlen(vname));
                if (imap_utf7_to_utf8(vname, str) == 0) {
-                       if (list->set.broken_char != '\0')
+                       if (list->set.vname_escape_char != '\0')
                                mailbox_list_escape_broken_chars(list, str);
                        vname = str_c(str);
-               } else if (list->set.broken_char != '\0') {
+               } else if (list->set.vname_escape_char != '\0') {
                        mailbox_list_escape_broken_name(list, vname, str);
                        vname = str_c(str);
                }
index 7c6db5d536395f168d16c0ff26eb2b057e9ef86d..8c5f9f9068bbd9feca6ffef853f0d71aaeedcf44 100644 (file)
@@ -145,10 +145,10 @@ struct mailbox_list_settings {
        /* Encode "bad" characters in mailbox names as <escape_char><hex> */
        char storage_name_escape_char;
        /* If mailbox name can't be changed reversibly to UTF-8 and back,
-          encode the problematic parts using <broken_char><hex> in the
-          user-visible UTF-8 name. The broken_char itself also has to be
+          encode the problematic parts using <escape_char><hex> in the
+          user-visible UTF-8 name. The vname_escape_char itself also has to be
           encoded the same way. */
-       char broken_char;
+       char vname_escape_char;
        /* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */
        bool utf8;
        /* Don't check/create the alt-dir symlink. */