[PATCH v3 3/3] reply: Use RFC 2822/MIME wholly for text format template
authorAustin Clements <amdragon@MIT.EDU>
Fri, 16 Aug 2013 15:35:43 +0000 (11:35 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:21 +0000 (09:56 -0800)
60/323e43996d93de5883f129b0f9b9844221c279 [new file with mode: 0644]

diff --git a/60/323e43996d93de5883f129b0f9b9844221c279 b/60/323e43996d93de5883f129b0f9b9844221c279
new file mode 100644 (file)
index 0000000..6a972a4
--- /dev/null
@@ -0,0 +1,571 @@
+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 33F39429E50\r
+       for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 08:36:01 -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 SFlGLXruoWjq for <notmuch@notmuchmail.org>;\r
+       Fri, 16 Aug 2013 08:35:55 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu\r
+       [18.7.68.37])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5B3B5429E3E\r
+       for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 08:35:50 -0700 (PDT)\r
+X-AuditID: 12074425-b7f0c8e000000953-bb-520e46d661f5\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id BC.B5.02387.6D64E025; Fri, 16 Aug 2013 11:35:50 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r7GFZkW6026081; \r
+       Fri, 16 Aug 2013 11:35:46 -0400\r
+Received: from drake.dyndns.org\r
+       (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [216.15.114.40]) (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 r7GFZirq020148\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Fri, 16 Aug 2013 11:35:45 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1VAM40-0002vc-9P; Fri, 16 Aug 2013 11:35:44 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject:\r
+ [PATCH v3 3/3] reply: Use RFC 2822/MIME wholly for text format template\r
+Date: Fri, 16 Aug 2013 11:35:43 -0400\r
+Message-Id: <1376667343-10863-4-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1376667343-10863-1-git-send-email-amdragon@mit.edu>\r
+References: <1376667343-10863-1-git-send-email-amdragon@mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFprJKsWRmVeSWpSXmKPExsUixG6nrnvNjS/IYN8KVos9+7wsrt+cyWzx\r
+       ZuU8Vgdmj7unuTwOf13I4vFs1S3mAOYoLpuU1JzMstQifbsEroy/K7ewFzxuZqz49XU6ewPj\r
+       1ewuRk4OCQETidNPpzJC2GISF+6tZ+ti5OIQEtjHKHFn/TkWCGcjo8T1e+1MEM4dJoljM66w\r
+       QjhzGSXuNRwD62cT0JDYtn85mC0iIC2x8+5sVhCbWSBeou3FdnYQW1igQuJcx3kwm0VAVWLl\r
+       jMnMIDavgIPEoVNLmCHuUJTofjaBDcTmFHCU+Nz/iQXEFgKq2TFvKRtEvaDEyZlPgOIcQPPV\r
+       JdbPE4JYJS/RvHU28wRGoVlIqmYhVM1CUrWAkXkVo2xKbpVubmJmTnFqsm5xcmJeXmqRroVe\r
+       bmaJXmpK6SZGcKi7qO5gnHBI6RCjAAejEg8vw0TeICHWxLLiytxDjJIcTEqivPMc+YKE+JLy\r
+       UyozEosz4otKc1KLDzFKcDArifBuNQDK8aYkVlalFuXDpKQ5WJTEeZ8/PRsoJJCeWJKanZpa\r
+       kFoEk5Xh4FCS4F3oCtQoWJSanlqRlplTgpBm4uAEGc4DNHwPSA1vcUFibnFmOkT+FKMux4Xe\r
+       BZ8YhVjy8vNSpcR5nUGKBECKMkrz4ObAUtQrRnGgt4R5T4FU8QDTG9ykV0BLmICWTDrDC7Kk\r
+       JBEhJdXAaJf/5uP0DRUFx5/lS3ovNEma9OvuZeYjPHmKDW03av2UW6wj2GvPi51+8+pEKPcm\r
+       drvZKedttNccjL9T/b78i77eteUT6s/ETQ4Xcfpy/zv/BeOsd63v589pUHw6R+SowwHpWV9/\r
+       /BUpNvm+ufqHwqodRTmfM9907arv/nN89wKOCTfq5q5rXaXEUpyRaKjFXFScCADefccnLAMA        AA==\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 15:36:01 -0000\r
+\r
+Previously, reply's default text format used an odd mix of RFC 2045\r
+MIME encoding for the reply template's body and some made-up RFC\r
+2822-like UTF-8 format for the headers.  The intent was to present the\r
+headers to the user in a nice, un-encoded format, but this assumed\r
+that whatever ultimately sent the email would RFC 2047-encode the\r
+headers, while at the same time the body was already RFC 2045 encoded,\r
+so it assumed that whatever sent the email would *not* re-encode the\r
+body.\r
+\r
+This can be fixed by either producing a fully decoded UTF-8 reply\r
+template, or a fully encoded MIME-compliant RFC 2822 message.  This\r
+patch does the latter because it is\r
+\r
+a) Well-defined by RFC 2822 and MIME (while any UTF-8 format would be\r
+   ad hoc).\r
+\r
+b) Ready to be piped to sendmail.  The point of the text format is to\r
+   be minimal, so a user should be able to pop up the template in\r
+   whatever editor they want, edit it, and push it to sendmail.\r
+\r
+c) Consistent with frontend capabilities.  If a frontend has the\r
+   smarts to RFC 2047 encode the headers before sending the mail, it\r
+   probably has the smarts to RFC 2047 decode them before presenting\r
+   the template to a user for editing.\r
+\r
+Also, as far as I know, nothing automated consumes the reply text\r
+format, so changing this should not cause serious problems.  (And if\r
+anything does still consume this format, it probably gets these\r
+encoding issues wrong anyway.)\r
+---\r
+ Makefile.local           |    1 -\r
+ gmime-filter-headers.c   |  263 ----------------------------------------------\r
+ gmime-filter-headers.h   |   69 ------------\r
+ man/man1/notmuch-reply.1 |    2 +-\r
+ notmuch-reply.c          |   16 +--\r
+ test/reply               |    9 +-\r
+ test/reply-to-sender     |    4 +-\r
+ 7 files changed, 13 insertions(+), 351 deletions(-)\r
+ delete mode 100644 gmime-filter-headers.c\r
+ delete mode 100644 gmime-filter-headers.h\r
+\r
+diff --git a/Makefile.local b/Makefile.local\r
+index 84043fe..b7cd266 100644\r
+--- a/Makefile.local\r
++++ b/Makefile.local\r
+@@ -255,7 +255,6 @@ notmuch_client_srcs =              \\r
+       command-line-arguments.c\\r
+       debugger.c              \\r
+       gmime-filter-reply.c    \\r
+-      gmime-filter-headers.c  \\r
+       hooks.c                 \\r
+       notmuch.c               \\r
+       notmuch-config.c        \\r
+diff --git a/gmime-filter-headers.c b/gmime-filter-headers.c\r
+deleted file mode 100644\r
+index 7db3779..0000000\r
+--- a/gmime-filter-headers.c\r
++++ /dev/null\r
+@@ -1,263 +0,0 @@\r
+-/*\r
+- * Copyright © 2009 Keith Packard <keithp@keithp.com>\r
+- * Copyright © 2010 Michal Sojka <sojkam1@fel.cvut.cz>\r
+- *\r
+- * This program is free software; you can redistribute it and/or modify\r
+- * it under the terms of the GNU General Public License as published by\r
+- * the Free Software Foundation, either version 3 of the License, or\r
+- * (at your option) any later version.\r
+- *\r
+- * This program is distributed in the hope that it will be useful, but\r
+- * WITHOUT ANY WARRANTY; without even the implied warranty of\r
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+- * General Public License for more details.\r
+- *\r
+- * You should have received a copy of the GNU General Public License along\r
+- * with this program; if not, write to the Free Software Foundation, Inc.,\r
+- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.\r
+- */\r
+-\r
+-#include "gmime-filter-headers.h"\r
+-#include <string.h>\r
+-#include <gmime/gmime-utils.h>\r
+-#include <glib/gprintf.h>\r
+-#include <stdlib.h>\r
+-#include <xutil.h>\r
+-\r
+-/**\r
+- * SECTION: gmime-filter-headers\r
+- * @title: GMimeFilterHeaders\r
+- * @short_description: Add/remove headers markers\r
+- *\r
+- * A #GMimeFilter for decoding rfc2047 encoded headers to UTF-8\r
+- **/\r
+-\r
+-\r
+-static void g_mime_filter_headers_class_init (GMimeFilterHeadersClass *klass);\r
+-static void g_mime_filter_headers_init (GMimeFilterHeaders *filter, GMimeFilterHeadersClass *klass);\r
+-static void g_mime_filter_headers_finalize (GObject *object);\r
+-\r
+-static GMimeFilter *filter_copy (GMimeFilter *filter);\r
+-static void filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,\r
+-                         char **out, size_t *outlen, size_t *outprespace);\r
+-static void filter_complete (GMimeFilter *filter, char *in, size_t len, size_t prespace,\r
+-                           char **out, size_t *outlen, size_t *outprespace);\r
+-static void filter_reset (GMimeFilter *filter);\r
+-\r
+-\r
+-static GMimeFilterClass *parent_class = NULL;\r
+-\r
+-GType\r
+-g_mime_filter_headers_get_type (void)\r
+-{\r
+-      static GType type = 0;\r
+-\r
+-      if (!type) {\r
+-              static const GTypeInfo info = {\r
+-                      sizeof (GMimeFilterHeadersClass),\r
+-                      NULL, /* base_class_init */\r
+-                      NULL, /* base_class_finalize */\r
+-                      (GClassInitFunc) g_mime_filter_headers_class_init,\r
+-                      NULL, /* class_finalize */\r
+-                      NULL, /* class_data */\r
+-                      sizeof (GMimeFilterHeaders),\r
+-                      0,    /* n_preallocs */\r
+-                      (GInstanceInitFunc) g_mime_filter_headers_init,\r
+-                      NULL    /* value_table */\r
+-              };\r
+-\r
+-              type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterHeaders", &info, (GTypeFlags) 0);\r
+-      }\r
+-\r
+-      return type;\r
+-}\r
+-\r
+-\r
+-static void\r
+-g_mime_filter_headers_class_init (GMimeFilterHeadersClass *klass)\r
+-{\r
+-      GObjectClass *object_class = G_OBJECT_CLASS (klass);\r
+-      GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);\r
+-\r
+-      parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER);\r
+-\r
+-      object_class->finalize = g_mime_filter_headers_finalize;\r
+-\r
+-      filter_class->copy = filter_copy;\r
+-      filter_class->filter = filter_filter;\r
+-      filter_class->complete = filter_complete;\r
+-      filter_class->reset = filter_reset;\r
+-}\r
+-\r
+-static void\r
+-g_mime_filter_headers_init (GMimeFilterHeaders *filter, GMimeFilterHeadersClass *klass)\r
+-{\r
+-      (void) klass;\r
+-      filter->saw_nl = TRUE;\r
+-      filter->line = NULL;\r
+-      filter->line_size = 0;\r
+-      filter->lineptr = NULL;\r
+-}\r
+-\r
+-static void\r
+-g_mime_filter_headers_finalize (GObject *object)\r
+-{\r
+-      free (GMIME_FILTER_HEADERS (object)->line);\r
+-      G_OBJECT_CLASS (parent_class)->finalize (object);\r
+-}\r
+-\r
+-\r
+-static GMimeFilter *\r
+-filter_copy (GMimeFilter *filter)\r
+-{\r
+-      (void) filter;\r
+-      return g_mime_filter_headers_new ();\r
+-}\r
+-\r
+-static void\r
+-output_decoded_header (GMimeFilterHeaders *headers, char **outptr)\r
+-{\r
+-      char *colon, *name, *s, *decoded_value;\r
+-      size_t offset;\r
+-      gint ret;\r
+-\r
+-      colon = strchr (headers->line, ':');\r
+-      if (colon == NULL)\r
+-              return;\r
+-\r
+-      name = headers->line;\r
+-      *colon = '\0';\r
+-      s = colon + 1;\r
+-      while (*s == ' ' || *s == '\t')\r
+-              s++;\r
+-      decoded_value = g_mime_utils_header_decode_text(s);\r
+-      if (decoded_value == NULL)\r
+-              return;\r
+-      offset = *outptr - GMIME_FILTER (headers)->outbuf;\r
+-      g_mime_filter_set_size (GMIME_FILTER (headers), strlen(name) + 2 +\r
+-                             strlen(decoded_value) + 2, TRUE);\r
+-      *outptr = GMIME_FILTER (headers)->outbuf + offset;\r
+-      ret = g_sprintf (*outptr, "%s: %s\n", name, decoded_value);\r
+-      if (ret > 0)\r
+-              *outptr += ret;\r
+-      free (decoded_value);\r
+-}\r
+-\r
+-static void\r
+-output_final_newline (GMimeFilterHeaders *headers, char **outptr)\r
+-{\r
+-      size_t offset;\r
+-\r
+-      offset = *outptr - GMIME_FILTER (headers)->outbuf;\r
+-      g_mime_filter_set_size (GMIME_FILTER (headers), 1, TRUE);\r
+-      *outptr = GMIME_FILTER (headers)->outbuf + offset;\r
+-      *(*outptr)++ = '\n';\r
+-}\r
+-\r
+-static void\r
+-filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,\r
+-             char **outbuf, size_t *outlen, size_t *outprespace)\r
+-{\r
+-      GMimeFilterHeaders *headers = (GMimeFilterHeaders *) filter;\r
+-      register const char *inptr = inbuf;\r
+-      const char *inend = inbuf + inlen;\r
+-      char *lineptr, *lineend, *outptr;\r
+-\r
+-      (void) prespace;\r
+-      if (headers->line == NULL) {\r
+-              headers->line_size = 200;\r
+-              headers->lineptr = headers->line = malloc (headers->line_size);\r
+-      }\r
+-      lineptr = headers->lineptr;\r
+-      lineend = headers->line + headers->line_size - 1;\r
+-      if (lineptr == NULL)\r
+-              return;\r
+-      outptr = filter->outbuf;\r
+-      while (inptr < inend) {\r
+-              if (*inptr == '\n') {\r
+-                      if (headers->saw_nl)\r
+-                              output_final_newline(headers, &outptr);\r
+-                      headers->saw_nl = TRUE;\r
+-                      inptr++;\r
+-                      continue;\r
+-              }\r
+-\r
+-              if (lineptr == lineend) {\r
+-                      headers->line_size *= 2;\r
+-                      headers->line = xrealloc (headers->line, headers->line_size);\r
+-                      lineptr = headers->line + (headers->line_size / 2) - 1;\r
+-                      lineend = headers->line + headers->line_size - 1;\r
+-              }\r
+-\r
+-              if (headers->saw_nl && *inptr != ' ' && *inptr != '\t') {\r
+-                      *lineptr = '\0';\r
+-                      output_decoded_header (headers, &outptr);\r
+-                      lineptr = headers->line;\r
+-              }\r
+-              if (headers->saw_nl && (*inptr == ' ' || *inptr == '\t')) {\r
+-                      *lineptr = ' ';\r
+-                      lineptr++;\r
+-                      while (inptr < inend && (*inptr == ' ' || *inptr == '\t'))\r
+-                              inptr++;\r
+-                      headers->saw_nl = FALSE;\r
+-                      continue;\r
+-              }\r
+-              headers->saw_nl = FALSE;\r
+-\r
+-              if (*inptr != '\r')\r
+-                      *lineptr++ = *inptr;\r
+-              inptr++;\r
+-      }\r
+-      if (headers->saw_nl) {\r
+-              *lineptr = '\0';\r
+-              output_decoded_header (headers, &outptr);\r
+-              lineptr = headers->line;\r
+-      }\r
+-      headers->lineptr = lineptr;\r
+-      *outlen = outptr - filter->outbuf;\r
+-      *outprespace = filter->outpre;\r
+-      *outbuf = filter->outbuf;\r
+-}\r
+-\r
+-static void\r
+-filter_complete (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,\r
+-               char **outbuf, size_t *outlen, size_t *outprespace)\r
+-{\r
+-      if (inbuf && inlen)\r
+-              filter_filter (filter, inbuf, inlen, prespace, outbuf, outlen, outprespace);\r
+-}\r
+-\r
+-static void\r
+-filter_reset (GMimeFilter *filter)\r
+-{\r
+-      GMimeFilterHeaders *headers = (GMimeFilterHeaders *) filter;\r
+-\r
+-      headers->saw_nl = TRUE;\r
+-      free(headers->line);\r
+-      headers->line = NULL;\r
+-      headers->line_size = 0;\r
+-}\r
+-\r
+-\r
+-/**\r
+- * g_mime_filter_headers_new:\r
+- * @encode: %TRUE if the filter should encode or %FALSE otherwise\r
+- * @dots: encode/decode dots (as for SMTP)\r
+- *\r
+- * Creates a new #GMimeFilterHeaders filter.\r
+- *\r
+- * If @encode is %TRUE, then all lines will be prefixed by "> ",\r
+- * otherwise any lines starting with "> " will have that removed\r
+- *\r
+- * Returns: a new #GMimeFilterHeaders filter.\r
+- **/\r
+-GMimeFilter *\r
+-g_mime_filter_headers_new (void)\r
+-{\r
+-      GMimeFilterHeaders *new_headers;\r
+-\r
+-      new_headers = (GMimeFilterHeaders *) g_object_newv (GMIME_TYPE_FILTER_HEADERS, 0, NULL);\r
+-\r
+-      return (GMimeFilter *) new_headers;\r
+-}\r
+-\r
+diff --git a/gmime-filter-headers.h b/gmime-filter-headers.h\r
+deleted file mode 100644\r
+index 1d1a3eb..0000000\r
+--- a/gmime-filter-headers.h\r
++++ /dev/null\r
+@@ -1,69 +0,0 @@\r
+-/*\r
+- * Copyright © 2009 Keith Packard <keithp@keithp.com>\r
+- * Copyright © 2010 Michal Sojka <sojkam1@fel.cvut.cz>\r
+- *\r
+- * This program is free software; you can redistribute it and/or modify\r
+- * it under the terms of the GNU General Public License as published by\r
+- * the Free Software Foundation, either version 3 of the License, or\r
+- * (at your option) any later version.\r
+- *\r
+- * This program is distributed in the hope that it will be useful, but\r
+- * WITHOUT ANY WARRANTY; without even the implied warranty of\r
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+- * General Public License for more details.\r
+- *\r
+- * You should have received a copy of the GNU General Public License along\r
+- * with this program; if not, write to the Free Software Foundation, Inc.,\r
+- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.\r
+- */\r
+-\r
+-#ifndef _GMIME_FILTER_HEADERS_H_\r
+-#define _GMIME_FILTER_HEADERS_H_\r
+-\r
+-#include <gmime/gmime-filter.h>\r
+-\r
+-G_BEGIN_DECLS\r
+-\r
+-#define GMIME_TYPE_FILTER_HEADERS            (g_mime_filter_headers_get_type ())\r
+-#define GMIME_FILTER_HEADERS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_FILTER_HEADERS, GMimeFilterHeaders))\r
+-#define GMIME_FILTER_HEADERS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_FILTER_HEADERS, GMimeFilterHeadersClass))\r
+-#define GMIME_IS_FILTER_HEADERS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_FILTER_HEADERS))\r
+-#define GMIME_IS_FILTER_HEADERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_FILTER_HEADERS))\r
+-#define GMIME_FILTER_HEADERS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_FILTER_HEADERS, GMimeFilterHeadersClass))\r
+-\r
+-typedef struct _GMimeFilterHeaders GMimeFilterHeaders;\r
+-typedef struct _GMimeFilterHeadersClass GMimeFilterHeadersClass;\r
+-\r
+-/**\r
+- * GMimeFilterHeaders:\r
+- * @parent_object: parent #GMimeFilter\r
+- * @saw_nl: previous char was a \n\r
+- * @line: temporary buffer for line unfolding\r
+- * @line_size: size of currently allocated memory for @line\r
+- * @lineptr: pointer to the first unused character in @line\r
+- *\r
+- * A filter to decode rfc2047 encoded headers\r
+- **/\r
+-struct _GMimeFilterHeaders {\r
+-      GMimeFilter parent_object;\r
+-\r
+-      gboolean saw_nl;\r
+-      char *line;\r
+-      size_t line_size;\r
+-      char *lineptr;\r
+-};\r
+-\r
+-struct _GMimeFilterHeadersClass {\r
+-      GMimeFilterClass parent_class;\r
+-\r
+-};\r
+-\r
+-\r
+-GType g_mime_filter_headers_get_type (void);\r
+-\r
+-GMimeFilter *g_mime_filter_headers_new (void);\r
+-\r
+-G_END_DECLS\r
+-\r
+-\r
+-#endif /* _GMIME_FILTER_HEADERS_H_ */\r
+diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1\r
+index ac76b07..e553145 100644\r
+--- a/man/man1/notmuch-reply.1\r
++++ b/man/man1/notmuch-reply.1\r
+@@ -41,7 +41,7 @@ include\r
+ .RS\r
+ .TP 4\r
+ .BR default\r
+-Includes subject and quoted message body.\r
++Includes subject and quoted message body as an RFC 2822 message.\r
+ .TP\r
+ .BR json\r
+ Produces JSON output containing headers for a reply message and the\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 472a002..ac46d02 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -21,28 +21,18 @@\r
+  */\r
\r
+ #include "notmuch-client.h"\r
+-#include "gmime-filter-headers.h"\r
+ #include "sprinter.h"\r
\r
+ static void\r
+ show_reply_headers (GMimeMessage *message)\r
+ {\r
+-    GMimeStream *stream_stdout = NULL, *stream_filter = NULL;\r
++    GMimeStream *stream_stdout = NULL;\r
\r
+     stream_stdout = g_mime_stream_file_new (stdout);\r
+     if (stream_stdout) {\r
+       g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);\r
+-      stream_filter = g_mime_stream_filter_new(stream_stdout);\r
+-      if (stream_filter) {\r
+-              // g_mime_object_write_to_stream will produce\r
+-              // RFC2047-encoded headers, but we want to present the\r
+-              // user with decoded headers and let whatever\r
+-              // ultimately sends the mail do the RFC2047 encoding.\r
+-              g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),\r
+-                                       g_mime_filter_headers_new());\r
+-              g_mime_object_write_to_stream(GMIME_OBJECT(message), stream_filter);\r
+-              g_object_unref(stream_filter);\r
+-      }\r
++      /* Output RFC 2822 formatted (and RFC 2047 encoded) headers. */\r
++      g_mime_object_write_to_stream (GMIME_OBJECT(message), stream_stdout);\r
+       g_object_unref(stream_stdout);\r
+     }\r
+ }\r
+diff --git a/test/reply b/test/reply\r
+index a85ebe5..d4389cf 100755\r
+--- a/test/reply\r
++++ b/test/reply\r
+@@ -132,7 +132,9 @@ add_message '[subject]="This subject is exactly 200 bytes in length. Other than\r
+           '[body]="200-byte header"'\r
+ output=$(notmuch reply id:${gen_msg_id})\r
+ test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+-Subject: Re: This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces\r
++Subject: Re: This subject is exactly 200 bytes in length. Other than its\r
++ length there is not much of note here. Note that the length of 200 bytes\r
++ includes the Subject: and Re: prefixes with two spaces\r
+ In-Reply-To: <${gen_msg_id}>\r
+ References: <${gen_msg_id}>\r
\r
+@@ -200,10 +202,11 @@ add_message '[subject]="=?iso-8859-1?q?=e0=df=e7?="' \\r
+           '[body]="Encoding"'\r
\r
+ output=$(notmuch reply id:${gen_msg_id})\r
++# Note that GMime changes from Q- to B-encoding\r
+ test_expect_equal "$output" "\\r
+ From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+-Subject: Re: àßç\r
+-To: ☃ <snowman@example.com>\r
++Subject: Re: =?iso-8859-1?b?4N/n?=\r
++To: =?UTF-8?b?4piD?= <snowman@example.com>\r
+ In-Reply-To: <${gen_msg_id}>\r
+ References: <${gen_msg_id}>\r
\r
+diff --git a/test/reply-to-sender b/test/reply-to-sender\r
+index c7d15bb..30e5e38 100755\r
+--- a/test/reply-to-sender\r
++++ b/test/reply-to-sender\r
+@@ -200,7 +200,9 @@ add_message '[subject]="This subject is exactly 200 bytes in length. Other than\r
+             '[body]="200-byte header"'\r
+ output=$(notmuch reply  --reply-to=sender id:${gen_msg_id})\r
+ test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+-Subject: Re: This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces\r
++Subject: Re: This subject is exactly 200 bytes in length. Other than its\r
++ length there is not much of note here. Note that the length of 200 bytes\r
++ includes the Subject: and Re: prefixes with two spaces\r
+ In-Reply-To: <${gen_msg_id}>\r
+ References: <${gen_msg_id}>\r
\r
+-- \r
+1.7.10.4\r
+\r