unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Cc: tomi.ollila@iki.fi
Subject: [PATCH v2 2/3] reply: Remove extraneous space from generated References
Date: Thu, 15 Aug 2013 13:27:37 -0400	[thread overview]
Message-ID: <1376587658-19202-3-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1376587658-19202-1-git-send-email-amdragon@mit.edu>

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 two tests 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 +-
 test/reply      |    2 +-
 3 files changed, 10 insertions(+), 8 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@notmuchmail.org>",
  "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",
  "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",
- "References": " <87liy5ap00.fsf@yoom.home.cworth.org>"},
+ "References": "<87liy5ap00.fsf@yoom.home.cworth.org>"},
  "original": {"id": "XXXXX",
  "match": false,
  "excluded": false,
diff --git a/test/reply b/test/reply
index c877ffe..a85ebe5 100755
--- a/test/reply
+++ b/test/reply
@@ -242,7 +242,7 @@ test_expect_equal_json "$output" '
     "reply-headers": {
         "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
         "In-reply-to": "<'${gen_msg_id}'>",
-        "References": " <'${gen_msg_id}'>",
+        "References": "<'${gen_msg_id}'>",
         "Subject": "Re: \u00e0\u00df\u00e7",
         "To": "\u2603 <snowman@example.com>"
     }
-- 
1.7.10.4

  parent reply	other threads:[~2013-08-15 17:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-15 17:27 [PATCH v2 0/3] Clean up reply's encoding story Austin Clements
2013-08-15 17:27 ` [PATCH v2 1/3] reply: Test replying to messages with RFC 2047-encoded headers Austin Clements
2013-08-15 17:27 ` Austin Clements [this message]
2013-08-16 14:19   ` [PATCH v2 2/3] reply: Remove extraneous space from generated References Jani Nikula
2013-08-16 15:15     ` Austin Clements
2013-08-15 17:27 ` [PATCH v2 3/3] reply: Use RFC 2822/MIME wholly for text format template Austin Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376587658-19202-3-git-send-email-amdragon@mit.edu \
    --to=amdragon@mit.edu \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).