]> granicus.if.org Git - neomutt/commitdiff
tags: fix multiple tags set on multiple emails
authorMehdi Abaakouk <sileht@sileht.net>
Mon, 14 Jan 2019 20:16:02 +0000 (21:16 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 15 Jan 2019 11:51:15 +0000 (11:51 +0000)
When we set multiple tags on multiple emails at once, only the first
email get all tags.

This is because we use strsep that will modify the initial buffer that
contains all tags.

This change fixes it by duplicating the buffer of tags before using
strsep on it.

email/tags.c
imap/imap.c

index f72765039ea480177340e263f3fa1cc61e5b364d..7042f4b554294b799b66146e0d1404c5c17243f1 100644 (file)
@@ -198,9 +198,10 @@ bool driver_tags_replace(struct TagHead *head, char *tags)
   if (tags)
   {
     char *tag = NULL;
-    while ((tag = strsep(&tags, " ")))
+    char *split_tags = mutt_str_strdup(tags);
+    while ((tag = strsep(&split_tags, " ")))
       driver_tags_add(head, tag);
-    FREE(&tags);
+    FREE(&split_tags);
   }
   return true;
 }
index bba5a764c9500a9a2418363261ee38c326b07c4d..51cf8023a3f488f243483a27e72c48963ca3be34 100644 (file)
@@ -2445,7 +2445,7 @@ static int imap_tags_commit(struct Mailbox *m, struct Email *e, char *buf)
   }
 
   /* We are good sync them */
-  mutt_debug(1, "NEW TAGS: %d\n", buf);
+  mutt_debug(1, "NEW TAGS: %s\n", buf);
   driver_tags_replace(&e->tags, buf);
   FREE(&imap_edata_get(e)->flags_remote);
   imap_edata_get(e)->flags_remote = driver_tags_get_with_hidden(&e->tags);