]> git.notmuchmail.org Git - notmuch/commitdiff
reply: Remove extraneous space from generated References
authorAustin Clements <amdragon@MIT.EDU>
Fri, 16 Aug 2013 15:35:42 +0000 (11:35 -0400)
committerDavid Bremner <bremner@debian.org>
Sat, 17 Aug 2013 07:05:44 +0000 (09:05 +0200)
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
test/multipart
test/reply

index 3b2b58d194dfb8f1be470dfd6d04fbf2393af45c..472a002ec2136c02a588598782c1da98ee3d8b16 100644 (file)
@@ -537,9 +537,12 @@ create_reply_message(void *ctx,
                              "In-Reply-To", in_reply_to);
 
     orig_references = notmuch_message_get_header (message, "references");
+    if (!orig_references)
+       /* Treat errors like missing References headers. */
+       orig_references = "";
     references = talloc_asprintf (ctx, "%s%s%s",
-                                 orig_references ? orig_references : "",
-                                 orig_references ? " " : "",
+                                 *orig_references ? orig_references : "",
+                                 *orig_references ? " " : "",
                                  in_reply_to);
     g_mime_object_set_header (GMIME_OBJECT (reply),
                              "References", references);
index c974226efd773ba46fd5be9f900919d3aa29fbcc..2033023afd408f4ff3a6e2ee35e73bca99e13433 100755 (executable)
@@ -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,
index c877ffe10ba91219d86d0363fe4560a9cbda4029..a85ebe56e30f20e8176222c91bf06e5fe3f8ab08 100755 (executable)
@@ -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>"
     }