mu_maildir_get_new_path() did not use the right flags separator when creating new file names.

This commit is contained in:
Juan Jose Garcia-Ripoll
2020-10-10 18:20:16 +02:00
parent 8ce966778a
commit e47c1f4f28

View File

@ -779,6 +779,18 @@ get_new_basename (void)
g_get_host_name ());
}
static const char*
get_path_separator(const char *path)
{
const char *cur;
for (cur = &path[strlen(path)-1]; cur > path; --cur) {
if ((*cur == ':' || *cur == '!' || *cur == ';') &&
(cur[1] == '2' && cur[2] == ',')) {
return cur;
}
}
return NULL;
}
char*
mu_maildir_get_new_path (const char *oldpath, const char *new_mdir,
@ -795,16 +807,22 @@ mu_maildir_get_new_path (const char *oldpath, const char *new_mdir,
if (!mdir)
return NULL;
if (new_name)
/* determine the name of the location of the flag separator */
if (new_name) {
const char *cur;
mfile = get_new_basename ();
else {
/* determine the name of the mailfile, stripped of its flags, as
* well as any custom (non-standard) flags */
cur = get_path_separator (oldpath);
if (cur) {
/* preserve the existing flags separator
* in the new file name */
flags_sep = *cur;
}
} else {
char *cur;
mfile = g_path_get_basename (oldpath);
for (cur = &mfile[strlen(mfile)-1]; cur > mfile; --cur) {
if ((*cur == ':' || *cur == '!' || *cur == ';') &&
(cur[1] == '2' && cur[2] == ',')) {
cur = (char*) get_path_separator (mfile);
if (cur) {
/* get the custom flags (if any) */
custom_flags =
mu_flags_custom_from_str (cur + 3);
@ -812,8 +830,6 @@ mu_maildir_get_new_path (const char *oldpath, const char *new_mdir,
* in the new file name */
flags_sep = *cur;
cur[0] = '\0'; /* strip the flags */
break;
}
}
}