[notmuch] [PATCH] Filter out carriage-returns in show and reply output.
authorKeith Packard <keithp@keithp.com>
Wed, 18 Nov 2009 19:56:13 +0000 (11:56 +1600)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:35:36 +0000 (09:35 -0800)
ad/65c3647a191e6707fc0ade26381239f34f31ca [new file with mode: 0644]

diff --git a/ad/65c3647a191e6707fc0ade26381239f34f31ca b/ad/65c3647a191e6707fc0ade26381239f34f31ca
new file mode 100644 (file)
index 0000000..5ed38f1
--- /dev/null
@@ -0,0 +1,119 @@
+Return-Path: <keithp@keithp.com>\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 D8CA8431FBC\r
+       for <notmuch@notmuchmail.org>; Wed, 18 Nov 2009 11:56:24 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 aRx-6oOVOCf5 for <notmuch@notmuchmail.org>;\r
+       Wed, 18 Nov 2009 11:56:23 -0800 (PST)\r
+Received: from keithp.com (home.keithp.com [63.227.221.253])\r
+       by olra.theworths.org (Postfix) with ESMTP id 12328431FAE\r
+       for <notmuch@notmuchmail.org>; Wed, 18 Nov 2009 11:56:23 -0800 (PST)\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by keithp.com (Postfix) with ESMTP id 150DEB9404C\r
+       for <notmuch@notmuchmail.org>; Wed, 18 Nov 2009 11:56:21 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at keithp.com\r
+Received: from keithp.com ([127.0.0.1])\r
+       by localhost (keithp.com [127.0.0.1]) (amavisd-new, port 10024)\r
+       with LMTP id wCZMnIzscRaV; Wed, 18 Nov 2009 11:56:15 -0800 (PST)\r
+Received: by keithp.com (Postfix, from userid 1033)\r
+       id 47B3DB9402F; Wed, 18 Nov 2009 11:56:15 -0800 (PST)\r
+Received: from koto.keithp.com (localhost [127.0.0.1])\r
+       by keithp.com (Postfix) with ESMTP id 3B1A1B88003;\r
+       Wed, 18 Nov 2009 11:56:15 -0800 (PST)\r
+Received: by koto.keithp.com (Postfix, from userid 1488)\r
+       id CE9901581A5; Wed, 18 Nov 2009 11:56:14 -0800 (PST)\r
+From: Keith Packard <keithp@keithp.com>\r
+To: notmuch@notmuchmail.org\r
+Date: Wed, 18 Nov 2009 11:56:13 -0800\r
+Message-Id: <1258574173-19911-1-git-send-email-keithp@keithp.com>\r
+X-Mailer: git-send-email 1.6.5.2\r
+Subject: [notmuch] [PATCH] Filter out carriage-returns in show and reply\r
+       output.\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\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: Wed, 18 Nov 2009 19:56:25 -0000\r
+\r
+Thanks, windows mail clients.\r
+\r
+Signed-off-by: Keith Packard <keithp@keithp.com>\r
+---\r
+ gmime-filter-reply.c |    7 ++++---\r
+ notmuch-show.c       |   21 +++++++++++++++------\r
+ 2 files changed, 19 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/gmime-filter-reply.c b/gmime-filter-reply.c\r
+index 3e298e1..b269db4 100644\r
+--- a/gmime-filter-reply.c\r
++++ b/gmime-filter-reply.c\r
+@@ -130,8 +130,9 @@ filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,\r
+                               reply->saw_nl = TRUE;\r
+                       else\r
+                               reply->saw_nl = FALSE;\r
+-\r
+-                      *outptr++ = *inptr++;\r
++                      if (*inptr != '\r')\r
++                              *outptr++ = *inptr;\r
++                      inptr++;\r
+               }\r
+       } else {\r
+               g_mime_filter_set_size (filter, inlen + 1, FALSE);\r
+@@ -150,7 +151,7 @@ filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,\r
+                               else\r
+                                       *outptr++ = *inptr;\r
+                               reply->saw_angle = FALSE;\r
+-                      } else {\r
++                      } else if (*inptr != '\r') {\r
+                               if (*inptr == '\n')\r
+                                       reply->saw_nl = TRUE;\r
+                               *outptr++ = *inptr;\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 7749dbc..4c377e1 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -99,14 +99,23 @@ show_part (GMimeObject *part, int *part_count)\r
+     if (g_mime_content_type_is_type (content_type, "text", "*") &&\r
+       !g_mime_content_type_is_type (content_type, "text", "html"))\r
+     {\r
+-      GMimeStream *stream = g_mime_stream_file_new (stdout);\r
+-      g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), FALSE);\r
++      GMimeStream *stream_stdout = g_mime_stream_file_new (stdout);\r
++      GMimeStream *stream_filter = NULL;\r
++      \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
++          g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),\r
++                                   g_mime_filter_crlf_new(FALSE, FALSE));\r
++      }\r
\r
+       wrapper = g_mime_part_get_content_object (GMIME_PART (part));\r
+-      if (wrapper && stream)\r
+-          g_mime_data_wrapper_write_to_stream (wrapper, stream);\r
+-      if (stream)\r
+-          g_object_unref(stream);\r
++      if (wrapper && stream_filter)\r
++          g_mime_data_wrapper_write_to_stream (wrapper, stream_filter);\r
++      if (stream_filter)\r
++          g_object_unref(stream_filter);\r
++      if (stream_stdout)\r
++          g_object_unref(stream_stdout);\r
+     }\r
+     else\r
+     {\r
+-- \r
+1.6.5.2\r
+\r