[PATCH 2/2] Make parsing of References and In-Reply-To header less error prone

2014-07-13 Thread David Bremner
Michal Sojka  writes:

> 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.

This series looks OK to me.  It does touch something pretty fundamental,
so I'd appreciate a second set of eyes on it.

d


Re: [PATCH 2/2] Make parsing of References and In-Reply-To header less error prone

2014-07-13 Thread David Bremner
Michal Sojka sojk...@fel.cvut.cz writes:

 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.

This series looks OK to me.  It does touch something pretty fundamental,
so I'd appreciate a second set of eyes on it.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] Make parsing of References and In-Reply-To header less error prone

2014-05-26 Thread Michal Sojka
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
---
 lib/database.cc | 15 ++-
 test/T510-thread-replies.sh |  1 -
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 1efb14d..26f15fd 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -521,7 +521,7 @@ parse_references (void *ctx,
  GHashTable *hash,
  const char *refs)
 {
-char *ref;
+char *ref, *last_ref = NULL;

 if (refs == NULL || *refs == '\0')
return NULL;
@@ -529,20 +529,17 @@ parse_references (void *ctx,
 while (*refs) {
ref = _parse_message_id (ctx, refs, );

-   if (ref && strcmp (ref, message_id))
+   if (ref && strcmp (ref, message_id)) {
g_hash_table_insert (hash, ref, NULL);
+   last_ref = ref;
+   }
 }

 /* The return value of this function is used to add a parent
  * reference to the database.  We should avoid making a message
- * its own parent, thus the following check.
+ * its own parent, thus the above check.
  */
-
-if (ref && strcmp(ref, message_id)) {
-   return ref;
-} else {
-   return NULL;
-}
+return last_ref;
 }

 notmuch_status_t
diff --git a/test/T510-thread-replies.sh b/test/T510-thread-replies.sh
index d818b89..1392fbe 100755
--- a/test/T510-thread-replies.sh
+++ b/test/T510-thread-replies.sh
@@ -138,7 +138,6 @@ expected=`echo "$expected" | notmuch_json_show_sanitize`
 test_expect_equal_json "$output" "$expected"

 test_begin_subtest "Ignore garbage at the end of References"
-test_subtest_known_broken
 add_message '[id]="foo at five.com"' \
 '[subject]="five"'
 add_message '[id]="bar at five.com"' \
-- 
2.0.0.rc2