Re: [PATCH v2 2/3] reply: Remove extraneous space from generated References
authorJani Nikula <jani@nikula.org>
Fri, 16 Aug 2013 14:19:25 +0000 (17:19 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:19 +0000 (09:56 -0800)
3a/c1854638c28e4276dd71ef0d56b49168112c57 [new file with mode: 0644]

diff --git a/3a/c1854638c28e4276dd71ef0d56b49168112c57 b/3a/c1854638c28e4276dd71ef0d56b49168112c57
new file mode 100644 (file)
index 0000000..1f8821a
--- /dev/null
@@ -0,0 +1,152 @@
+Return-Path: <jani@nikula.org>\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 171F9431E82\r
+       for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 07:19:29 -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 1pNfV3s1Gmtk for <notmuch@notmuchmail.org>;\r
+       Fri, 16 Aug 2013 07:19:21 -0700 (PDT)\r
+Received: from mail-bk0-f43.google.com (mail-bk0-f43.google.com\r
+       [209.85.214.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A41E5431FAF\r
+       for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 07:19:21 -0700 (PDT)\r
+Received: by mail-bk0-f43.google.com with SMTP id mz13so647337bkb.16\r
+       for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 07:19:20 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=x-gm-message-state:from:to:cc:subject:in-reply-to:references\r
+       :user-agent:date:message-id:mime-version:content-type;\r
+       bh=hY16oIruLu+VjIeOowyZzU7p588cbxV4sV7KgckgtGc=;\r
+       b=TOT8Scc1HPoeqfuv3RY8IX66fjY09M8l4hyLLwoRYNMj7w8ImdhJiA8jOL21X6Vv1P\r
+       SPnb//A1GdpLkOf6VeKa6q/mqS2S+kfZGZbWRihC9ly4E2dXBuQIGJPMxUKw6+O+IAV9\r
+       ZWCH31LT9mjNa7N9Qv8yrXgkL5PV51Y35oC4W73MgzqZUuOWCQAs4Elo63Jp5AD7prwA\r
+       KXmJtHhmw0+dv1bS2aS2aUYsjve0QKhggPZ8R0PSL9BR/OAtoc34AUWgJVhjqsL4+HVQ\r
+       pibBO2DOtIB5t+oLdC5rZOyPq12TeJgq+jv8hqHZs4dO6m/Yj812cwJAAcZhAy9xD1zL\r
+       qtyw==\r
+X-Gm-Message-State:\r
+ ALoCoQmEMBC02BEZjplTjMPo6CMYtzm/YU/z6gX5gqAS/shGCIgwM5cKgocf9jGI26Ubtf63JSRu\r
+X-Received: by 10.204.77.72 with SMTP id f8mr920709bkk.28.1376662760251;\r
+       Fri, 16 Aug 2013 07:19:20 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+       [88.195.111.91])\r
+       by mx.google.com with ESMTPSA id 14sm362700bkl.17.1969.12.31.16.00.00\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Fri, 16 Aug 2013 07:19:19 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2 2/3] reply: Remove extraneous space from generated\r
+       References\r
+In-Reply-To: <1376587658-19202-3-git-send-email-amdragon@mit.edu>\r
+References: <1376587658-19202-1-git-send-email-amdragon@mit.edu>\r
+       <1376587658-19202-3-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.15.2+227~g40b2846 (http://notmuchmail.org) Emacs/24.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Fri, 16 Aug 2013 17:19:25 +0300\r
+Message-ID: <87k3jl3ehe.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Fri, 16 Aug 2013 14:19:29 -0000\r
+\r
+On Thu, 15 Aug 2013, Austin Clements <amdragon@MIT.EDU> wrote:\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
+If orig_references turned out to be NULL, wouldn't this then fail to add\r
+a References: header with in_reply_to in it?\r
+\r
+Jani.\r
+\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
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r