[PATCH 5/6] reply: Remove extraneous space from generated References

Austin Clements amdragon at MIT.EDU
Mon Aug 12 11:40:38 PDT 2013


Previously, the References header code seemed to assume
notmuch_message_get_header would return NULL if the header was not
present, but it actually returns "".  As a result of this, it was
inserting an unnecessary space when concatenating an empty or missing
original references header with the new reference.

This shows up in only one test because the text reply format later
passes the whole reply template through g_mime_filter_headers, which
has the side effect of stripping out this extra space.
---
 notmuch-reply.c |   14 ++++++++------
 test/multipart  |    2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 3b2b58d..0f3b9cd 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -537,12 +537,14 @@ create_reply_message(void *ctx,
 			      "In-Reply-To", in_reply_to);
 
     orig_references = notmuch_message_get_header (message, "references");
-    references = talloc_asprintf (ctx, "%s%s%s",
-				  orig_references ? orig_references : "",
-				  orig_references ? " " : "",
-				  in_reply_to);
-    g_mime_object_set_header (GMIME_OBJECT (reply),
-			      "References", references);
+    if (orig_references) {
+	references = talloc_asprintf (ctx, "%s%s%s",
+				      *orig_references ? orig_references : "",
+				      *orig_references ? " " : "",
+				      in_reply_to);
+	g_mime_object_set_header (GMIME_OBJECT (reply),
+				  "References", references);
+    }
 
     return reply;
 }
diff --git a/test/multipart b/test/multipart
index c974226..2033023 100755
--- a/test/multipart
+++ b/test/multipart
@@ -599,7 +599,7 @@ cat <<EOF >EXPECTED
  "From": "Notmuch Test Suite <test_suite at notmuchmail.org>",
  "To": "Carl Worth <cworth at cworth.org>, cworth at cworth.org",
  "In-reply-to": "<87liy5ap00.fsf at yoom.home.cworth.org>",
- "References": " <87liy5ap00.fsf at yoom.home.cworth.org>"},
+ "References": "<87liy5ap00.fsf at yoom.home.cworth.org>"},
  "original": {"id": "XXXXX",
  "match": false,
  "excluded": false,
-- 
1.7.10.4



More information about the notmuch mailing list