]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Use a better default vname escape character
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 26 Jan 2021 15:44:46 +0000 (17:44 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 3 Feb 2021 09:04:22 +0000 (09:04 +0000)
A control character was a bit unreadable in strings.

src/doveadm/doveadm-dsync.c

index 9d6159e6f6052851b19eda71493293c1a192f802..4b1fd9f61b54e0677441503675741435914c0338 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 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'
+/* The default vname_escape_char to use unless overridden by BROKENCHAR
+   setting. Note that it's only used for internal dsync names, so it won't end
+   up in permanent storage names. The only requirement for it is that it's not
+   the same as the hierarchy separator. */
+#define DSYNC_LIST_VNAME_ESCAPE_CHAR '%'
+/* In case DSYNC_LIST_VNAME_ESCAPE_CHAR is the hierarchy separator,
+   use this instead. */
+#define DSYNC_LIST_VNAME_ALT_ESCAPE_CHAR '~'
 
 #define DSYNC_DEFAULT_IO_STREAM_TIMEOUT_SECS (60*10)
 
@@ -325,11 +326,16 @@ static bool mirror_get_remote_cmd(struct dsync_cmd_context *ctx,
 static void doveadm_user_init_dsync(struct mail_user *user)
 {
        struct mail_namespace *ns;
+       char ns_sep = mail_namespaces_get_root_sep(user->namespaces);
 
        user->dsyncing = TRUE;
        for (ns = user->namespaces; ns != NULL; ns = ns->next) {
-               if (ns->list->set.vname_escape_char == '\0')
-                       ns->list->set.vname_escape_char = DSYNC_LIST_VNAME_ESCAPE_CHAR;
+               if (ns->list->set.vname_escape_char == '\0') {
+                       ns->list->set.vname_escape_char =
+                               ns_sep != DSYNC_LIST_VNAME_ESCAPE_CHAR ?
+                               DSYNC_LIST_VNAME_ESCAPE_CHAR :
+                               DSYNC_LIST_VNAME_ALT_ESCAPE_CHAR;
+               }
        }
 }