[PATCH v2 2/3] reply: Remove extraneous space from generated References
authorAustin Clements <amdragon@MIT.EDU>
Thu, 15 Aug 2013 17:27:37 +0000 (13:27 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:18 +0000 (09:56 -0800)
db/7012e14055fd9a9146f3bf96dc2df4f09a981a [new file with mode: 0644]

diff --git a/db/7012e14055fd9a9146f3bf96dc2df4f09a981a b/db/7012e14055fd9a9146f3bf96dc2df4f09a981a
new file mode 100644 (file)
index 0000000..66c87b0
--- /dev/null
@@ -0,0 +1,143 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id B104A429E26\r
+       for <notmuch@notmuchmail.org>; Thu, 15 Aug 2013 10:27:51 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id wf8A93JRZHB5 for <notmuch@notmuchmail.org>;\r
+       Thu, 15 Aug 2013 10:27:46 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu\r
+       [18.9.25.15])\r
+       by olra.theworths.org (Postfix) with ESMTP id B73A2431FC2\r
+       for <notmuch@notmuchmail.org>; Thu, 15 Aug 2013 10:27:46 -0700 (PDT)\r
+X-AuditID: 1209190f-b7fa58e000000953-5a-520d0f92e805\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id EB.47.02387.29F0D025; Thu, 15 Aug 2013 13:27:46 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r7FHRgK1000756; \r
+       Thu, 15 Aug 2013 13:27:42 -0400\r
+Received: from drake.dyndns.org (26-4-172.dynamic.csail.mit.edu [18.26.4.172])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r7FHReeN009075\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Thu, 15 Aug 2013 13:27:41 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1VA1Km-00053e-05; Thu, 15 Aug 2013 13:27:40 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 2/3] reply: Remove extraneous space from generated\r
+       References\r
+Date: Thu, 15 Aug 2013 13:27:37 -0400\r
+Message-Id: <1376587658-19202-3-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1376587658-19202-1-git-send-email-amdragon@mit.edu>\r
+References: <1376587658-19202-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsUixCmqrTuJnzfI4NIvNovrN2cyW7xZOY/V\r
+       gcnj8NeFLB7PVt1iDmCK4rJJSc3JLEst0rdL4MpY8/Ycc8EUkYppXVNYGxibBLoYOTgkBEwk\r
+       3l1X72LkBDLFJC7cW8/WxcjFISSwj1Fi0fFNLBDORkaJFy+WMUI4R5gk/i38xw7hzGWUaH+9\r
+       kB2kn01AQ2Lb/uWMILaIgLTEzruzWUFsZgEricNXN4HZwgIBEpca9oDZLAKqEsv/X2ADsXkF\r
+       HCQe9+xjhLhDUaL72QSwOKeAo8TKCffA4kJANfsXnmGbwMi/gJFhFaNsSm6Vbm5iZk5xarJu\r
+       cXJiXl5qka6JXm5miV5qSukmRnAoSfLvYPx2UOkQowAHoxIPb0Qbd5AQa2JZcWXuIUZJDiYl\r
+       Ud59fLxBQnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4v97jCRLiTUmsrEotyodJSXOwKInzPnt6\r
+       NlBIID2xJDU7NbUgtQgmK8PBoSTBGw4yVLAoNT21Ii0zpwQhzcTBCTKcB2h4KkgNb3FBYm5x\r
+       ZjpE/hSjLseFwws/MQqx5OXnpUqJ80aCFAmAFGWU5sHNgaWAV4ziQG8J85aDVPEA0wfcpFdA\r
+       S5iAljhkc4EsKUlESEk1MLa39FX630mbbscc7BLP2aSp9flNl2D/xnuTy9dl8ir08mfpLo51\r
+       Oc459bnwZqV8n5D1TrZWnlo7Zn+btXn7g10KRTzRaQv69P+f9Slsf7TjTLjJ2eAjYo/a7Nmb\r
+       Giy3Rpnl/TRLP3Dg7NsFGwLORNTlFVvpVe/WWRoUYrlwuTWvym1hyy4nJZbijERDLeai4kQA\r
+       n6KB4twCAAA=\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 15 Aug 2013 17:27:52 -0000\r
+\r
+Previously, the References header code seemed to assume\r
+notmuch_message_get_header would return NULL if the header was not\r
+present, but it actually returns "".  As a result of this, it was\r
+inserting an unnecessary space when concatenating an empty or missing\r
+original references header with the new reference.\r
+\r
+This shows up in only two tests because the text reply format later\r
+passes the whole reply template through g_mime_filter_headers, which\r
+has the side effect of stripping out this extra space.\r
+---\r
+ notmuch-reply.c |   14 ++++++++------\r
+ test/multipart  |    2 +-\r
+ test/reply      |    2 +-\r
+ 3 files changed, 10 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 3b2b58d..0f3b9cd 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -537,12 +537,14 @@ create_reply_message(void *ctx,\r
+                             "In-Reply-To", in_reply_to);\r
\r
+     orig_references = notmuch_message_get_header (message, "references");\r
+-    references = talloc_asprintf (ctx, "%s%s%s",\r
+-                                orig_references ? orig_references : "",\r
+-                                orig_references ? " " : "",\r
+-                                in_reply_to);\r
+-    g_mime_object_set_header (GMIME_OBJECT (reply),\r
+-                            "References", references);\r
++    if (orig_references) {\r
++      references = talloc_asprintf (ctx, "%s%s%s",\r
++                                    *orig_references ? orig_references : "",\r
++                                    *orig_references ? " " : "",\r
++                                    in_reply_to);\r
++      g_mime_object_set_header (GMIME_OBJECT (reply),\r
++                                "References", references);\r
++    }\r
\r
+     return reply;\r
+ }\r
+diff --git a/test/multipart b/test/multipart\r
+index c974226..2033023 100755\r
+--- a/test/multipart\r
++++ b/test/multipart\r
+@@ -599,7 +599,7 @@ cat <<EOF >EXPECTED\r
+  "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+  "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",\r
+  "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",\r
+- "References": " <87liy5ap00.fsf@yoom.home.cworth.org>"},\r
++ "References": "<87liy5ap00.fsf@yoom.home.cworth.org>"},\r
+  "original": {"id": "XXXXX",\r
+  "match": false,\r
+  "excluded": false,\r
+diff --git a/test/reply b/test/reply\r
+index c877ffe..a85ebe5 100755\r
+--- a/test/reply\r
++++ b/test/reply\r
+@@ -242,7 +242,7 @@ test_expect_equal_json "$output" '\r
+     "reply-headers": {\r
+         "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+         "In-reply-to": "<'${gen_msg_id}'>",\r
+-        "References": " <'${gen_msg_id}'>",\r
++        "References": "<'${gen_msg_id}'>",\r
+         "Subject": "Re: \u00e0\u00df\u00e7",\r
+         "To": "\u2603 <snowman@example.com>"\r
+     }\r
+-- \r
+1.7.10.4\r
+\r