lib: replace STRNCMP_LITERAL in __message_remove_indexed_terms

strncmp looks for a prefix that matches, which is very much not what
we want here. This fixes the bug reported by Franz Fellner in
id:1588595993-ner-8.651@TPL520
This commit is contained in:
David Bremner 2020-05-04 10:55:43 -03:00
parent accfee5c6e
commit 45cfeb2e55
2 changed files with 3 additions and 4 deletions

View file

@ -751,9 +751,9 @@ _notmuch_message_remove_indexed_terms (notmuch_message_t *message)
const char *tag = notmuch_tags_get (tags); const char *tag = notmuch_tags_get (tags);
if (STRNCMP_LITERAL (tag, "encrypted") != 0 && if (strcmp (tag, "encrypted") != 0 &&
STRNCMP_LITERAL (tag, "signed") != 0 && strcmp (tag, "signed") != 0 &&
STRNCMP_LITERAL (tag, "attachment") != 0) { strcmp (tag, "attachment") != 0) {
std::string term = tag_prefix + tag; std::string term = tag_prefix + tag;
message->doc.add_term (term); message->doc.add_term (term);
} }

View file

@ -34,7 +34,6 @@ notmuch dump > OUTPUT
test_expect_equal_file initial-dump OUTPUT test_expect_equal_file initial-dump OUTPUT
test_begin_subtest 'reindex preserves tags with special prefixes' test_begin_subtest 'reindex preserves tags with special prefixes'
test_subtest_known_broken
notmuch tag +attachment2 +encrypted2 +signed2 '*' notmuch tag +attachment2 +encrypted2 +signed2 '*'
notmuch dump > EXPECTED notmuch dump > EXPECTED
notmuch reindex '*' notmuch reindex '*'