mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 12:28:09 +01:00
Make parsing of References and In-Reply-To header less error prone
According to RFC2822 References and In-Reply-To headers are supposed to contain one or more Message-IDs, however older RFC822 allowed almost any content. When both References and In-Reply-To headers ends with something else that a Message-ID (see e.g. [1]), the thread structure presented by notmuch is incorrect. The reason is that notmuch treats this case as if the email contained no "replyto" information (see _notmuch_database_link_message_to_parents). This patch changes the parse_references() function to return the last valid Message-ID encountered rather than NULL resulting from the last hunk of text not being the Message-ID. [1] https://lkml.org/lkml/headers/2014/5/19/864
This commit is contained in:
parent
61993923b4
commit
028c56061e
2 changed files with 6 additions and 10 deletions
|
@ -524,7 +524,7 @@ parse_references (void *ctx,
|
||||||
GHashTable *hash,
|
GHashTable *hash,
|
||||||
const char *refs)
|
const char *refs)
|
||||||
{
|
{
|
||||||
char *ref;
|
char *ref, *last_ref = NULL;
|
||||||
|
|
||||||
if (refs == NULL || *refs == '\0')
|
if (refs == NULL || *refs == '\0')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -532,20 +532,17 @@ parse_references (void *ctx,
|
||||||
while (*refs) {
|
while (*refs) {
|
||||||
ref = _parse_message_id (ctx, refs, &refs);
|
ref = _parse_message_id (ctx, refs, &refs);
|
||||||
|
|
||||||
if (ref && strcmp (ref, message_id))
|
if (ref && strcmp (ref, message_id)) {
|
||||||
g_hash_table_insert (hash, ref, NULL);
|
g_hash_table_insert (hash, ref, NULL);
|
||||||
|
last_ref = ref;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The return value of this function is used to add a parent
|
/* The return value of this function is used to add a parent
|
||||||
* reference to the database. We should avoid making a message
|
* reference to the database. We should avoid making a message
|
||||||
* its own parent, thus the following check.
|
* its own parent, thus the above check.
|
||||||
*/
|
*/
|
||||||
|
return last_ref;
|
||||||
if (ref && strcmp(ref, message_id)) {
|
|
||||||
return ref;
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
|
|
|
@ -138,7 +138,6 @@ expected=`echo "$expected" | notmuch_json_show_sanitize`
|
||||||
test_expect_equal_json "$output" "$expected"
|
test_expect_equal_json "$output" "$expected"
|
||||||
|
|
||||||
test_begin_subtest "Ignore garbage at the end of References"
|
test_begin_subtest "Ignore garbage at the end of References"
|
||||||
test_subtest_known_broken
|
|
||||||
add_message '[id]="foo@five.com"' \
|
add_message '[id]="foo@five.com"' \
|
||||||
'[subject]="five"'
|
'[subject]="five"'
|
||||||
add_message '[id]="bar@five.com"' \
|
add_message '[id]="bar@five.com"' \
|
||||||
|
|
Loading…
Reference in a new issue