Spaces need to be stripped when querying the Message-Id,
because notmuch stores them in Xapian with spaces stripped.
All double-quote characters need to be doubled to escape them,
otherwise they will be added as extra query terms outside the id.
empty_maildir($results_dir);
die "notmuch-mutt: cannot find Message-Id, abort.\n";
}
empty_maildir($results_dir);
die "notmuch-mutt: cannot find Message-Id, abort.\n";
}
- my $search_cmd = 'notmuch search --output=threads ' . shell_quote("id:$mid");
+
+ $mid =~ s/ //g; # notmuch strips spaces before storing Message-Id
+ $mid =~ s/"/""/g; # escape all double quote characters
+
+ my $search_cmd = 'notmuch search --output=threads ' . shell_quote(qq{id:"$mid"});
my $tid = `$search_cmd`; # get thread id
chomp($tid);
my $tid = `$search_cmd`; # get thread id
chomp($tid);
my $mid = get_message_id();
defined $mid or die "notmuch-mutt: cannot find Message-Id, abort.\n";
my $mid = get_message_id();
defined $mid or die "notmuch-mutt: cannot find Message-Id, abort.\n";
- system("notmuch", "tag", @_, "--", "id:$mid");
+ $mid =~ s/ //g; # notmuch strips spaces before storing Message-Id
+ $mid =~ s/"/""/g; # escape all double quote characters
+
+ system("notmuch", "tag", @_, "--", qq{id:"$mid"});