Re: [PATCH v2 1/4] cli: add --from option to reply to restrict guessing of the From...
authorJani Nikula <jani@nikula.org>
Sat, 4 Feb 2012 22:07:41 +0000 (00:07 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:07 +0000 (09:44 -0800)
35/abbef1d4b0d3287ec7985b9c48c2e22f722477 [new file with mode: 0644]

diff --git a/35/abbef1d4b0d3287ec7985b9c48c2e22f722477 b/35/abbef1d4b0d3287ec7985b9c48c2e22f722477
new file mode 100644 (file)
index 0000000..9d01c70
--- /dev/null
@@ -0,0 +1,196 @@
+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 49795431FAF\r
+       for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 14:07:49 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       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 D23wS5OJWsIa for <notmuch@notmuchmail.org>;\r
+       Sat,  4 Feb 2012 14:07:48 -0800 (PST)\r
+Received: from mail-lpp01m020-f181.google.com (mail-lpp01m020-f181.google.com\r
+       [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 42E5D431FAE\r
+       for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 14:07:48 -0800 (PST)\r
+Received: by lbbgn5 with SMTP id gn5so1149794lbb.26\r
+       for <notmuch@notmuchmail.org>; Sat, 04 Feb 2012 14:07:45 -0800 (PST)\r
+Received: by 10.112.98.37 with SMTP id ef5mr3336137lbb.73.1328393265450;\r
+       Sat, 04 Feb 2012 14:07:45 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.\r
+       [84.248.80.253])\r
+       by mx.google.com with ESMTPS id f2sm8577276lbw.5.2012.02.04.14.07.43\r
+       (version=SSLv3 cipher=OTHER); Sat, 04 Feb 2012 14:07:44 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2 1/4] cli: add --from option to reply to restrict\r
+       guessing of the From: header.\r
+In-Reply-To: <1328388317-20161-2-git-send-email-markwalters1009@gmail.com>\r
+References: <1328388317-20161-1-git-send-email-markwalters1009@gmail.com>\r
+       <1328388317-20161-2-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Notmuch/0.11+139~g4340989 (http://notmuchmail.org) Emacs/23.3.1\r
+       (i686-pc-linux-gnu)\r
+Date: Sun, 05 Feb 2012 00:07:41 +0200\r
+Message-ID: <87haz68d76.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Sat, 04 Feb 2012 22:07:49 -0000\r
+\r
+On Sat,  4 Feb 2012 20:45:14 +0000, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> Add an option --from= to notmuch-reply.c to restrict guessing of the\r
+> From: header. The existing logic looks as the main headers, then at\r
+> the delivery headers, and finally defaults to the config file address.\r
+> \r
+> This patch allows the user to restrict which of these guesses are\r
+> made.  Currently the supported values are:\r
+>        default|fallback-all    current behaviour\r
+>        fallback-received       fallback to delivery headers but not config file\r
+>        fallback-none        only look at from/reply-to/to/cc/ headers\r
+>        none                 From: header is always left empty\r
+\r
+The patch looks good. The "primary" option added in v2 is missing from\r
+the commit message, but no need to send a new version because of that.\r
+\r
+I didn't check the other patches in the series.\r
+\r
+BR,\r
+Jani.\r
+\r
+\r
+> \r
+> If the code does not find an allowed address it outputs an empty From:\r
+> line and the caller can decide how to respond.\r
+> ---\r
+>  notmuch-reply.c |   45 ++++++++++++++++++++++++++++++++++++---------\r
+>  1 files changed, 36 insertions(+), 9 deletions(-)\r
+> \r
+> diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+> index f55b1d2..8c73cb7 100644\r
+> --- a/notmuch-reply.c\r
+> +++ b/notmuch-reply.c\r
+> @@ -24,6 +24,15 @@\r
+>  #include "gmime-filter-reply.h"\r
+>  #include "gmime-filter-headers.h"\r
+>  \r
+> +/* The order here matters as we use '<' when deciding how to behave. */\r
+> +enum {\r
+> +    FROM_FALLBACK_ALL,\r
+> +    FROM_FALLBACK_RECEIVED,\r
+> +    FROM_FALLBACK_NONE,\r
+> +    FROM_NONE,\r
+> +    FROM_PRIMARY\r
+> +};\r
+> +\r
+>  static void\r
+>  reply_headers_message_part (GMimeMessage *message);\r
+>  \r
+> @@ -510,7 +519,8 @@ notmuch_reply_format_default(void *ctx,\r
+>                           notmuch_config_t *config,\r
+>                           notmuch_query_t *query,\r
+>                           notmuch_show_params_t *params,\r
+> -                         notmuch_bool_t reply_all)\r
+> +                         notmuch_bool_t reply_all,\r
+> +                         int from_select)\r
+>  {\r
+>      GMimeMessage *reply;\r
+>      notmuch_messages_t *messages;\r
+> @@ -542,15 +552,22 @@ notmuch_reply_format_default(void *ctx,\r
+>      from_addr = add_recipients_from_message (reply, config, message,\r
+>                                               reply_all);\r
+>  \r
+> -    if (from_addr == NULL)\r
+> +    if (from_addr == NULL && from_select <= FROM_FALLBACK_RECEIVED)\r
+>          from_addr = guess_from_received_header (config, message);\r
+>  \r
+> -    if (from_addr == NULL)\r
+> +    if ((from_addr == NULL && from_select <= FROM_FALLBACK_ALL) ||\r
+> +        from_select == FROM_PRIMARY)\r
+>          from_addr = notmuch_config_get_user_primary_email (config);\r
+>  \r
+> -    from_addr = talloc_asprintf (ctx, "%s <%s>",\r
+> -                                 notmuch_config_get_user_name (config),\r
+> -                                 from_addr);\r
+> +    /* If we have an address and we want an address print\r
+> +     * it. Otherwise set an empty From: header. */\r
+> +    if (from_addr != NULL && from_select != FROM_NONE) {\r
+> +        from_addr = talloc_asprintf (ctx, "%s <%s>",\r
+> +                                     notmuch_config_get_user_name (config),\r
+> +                                     from_addr);\r
+> +    } else {\r
+> +        from_addr = talloc_strdup (ctx, "");\r
+> +    }\r
+>      g_mime_object_set_header (GMIME_OBJECT (reply),\r
+>                                "From", from_addr);\r
+>  \r
+> @@ -590,7 +607,8 @@ notmuch_reply_format_headers_only(void *ctx,\r
+>                                notmuch_config_t *config,\r
+>                                notmuch_query_t *query,\r
+>                                unused (notmuch_show_params_t *params),\r
+> -                              notmuch_bool_t reply_all)\r
+> +                              notmuch_bool_t reply_all,\r
+> +                              unused (int from_select))\r
+>  {\r
+>      GMimeMessage *reply;\r
+>      notmuch_messages_t *messages;\r
+> @@ -657,10 +675,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+>      notmuch_query_t *query;\r
+>      char *query_string;\r
+>      int opt_index, ret = 0;\r
+> -    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all);\r
+> +    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all, int from_select);\r
+>      notmuch_show_params_t params = { .part = -1 };\r
+>      int format = FORMAT_DEFAULT;\r
+>      int reply_all = TRUE;\r
+> +    int from_select = FROM_FALLBACK_ALL;\r
+>      notmuch_bool_t decrypt = FALSE;\r
+>  \r
+>      notmuch_opt_desc_t options[] = {\r
+> @@ -672,6 +691,14 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+>        (notmuch_keyword_t []){ { "all", TRUE },\r
+>                                { "sender", FALSE },\r
+>                                { 0, 0 } } },\r
+> +    { NOTMUCH_OPT_KEYWORD, &from_select, "from", 'F',\r
+> +      (notmuch_keyword_t []){ { "default", FROM_FALLBACK_ALL },\r
+> +                              { "fallback-all", FROM_FALLBACK_ALL },\r
+> +                              { "fallback-received", FROM_FALLBACK_RECEIVED },\r
+> +                              { "fallback-none", FROM_FALLBACK_NONE },\r
+> +                              { "none", FROM_NONE },\r
+> +                              { "primary", FROM_PRIMARY },\r
+> +                              { 0, 0 } } },\r
+>      { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },\r
+>      { 0, 0, 0, 0, 0 }\r
+>      };\r
+> @@ -732,7 +759,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+>      return 1;\r
+>      }\r
+>  \r
+> -    if (reply_format_func (ctx, config, query, &params, reply_all) != 0)\r
+> +    if (reply_format_func (ctx, config, query, &params, reply_all, from_select) != 0)\r
+>      return 1;\r
+>  \r
+>      notmuch_query_destroy (query);\r
+> -- \r
+> 1.7.2.3\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r