Re: [BUG] Saving attachments containing UTF-8 chars
authorTomi Ollila <tomi.ollila@iki.fi>
Mon, 29 Oct 2012 16:31:42 +0000 (18:31 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:10 +0000 (09:50 -0800)
9c/c0f67353e662a637f0f438a3375e94434963f1 [new file with mode: 0644]

diff --git a/9c/c0f67353e662a637f0f438a3375e94434963f1 b/9c/c0f67353e662a637f0f438a3375e94434963f1
new file mode 100644 (file)
index 0000000..d6fdf3b
--- /dev/null
@@ -0,0 +1,121 @@
+Return-Path: <tomi.ollila@iki.fi>\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 CA658431FBC\r
+       for <notmuch@notmuchmail.org>; Mon, 29 Oct 2012 09:31:43 -0700 (PDT)\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 Z8F+0eZ34C1w for <notmuch@notmuchmail.org>;\r
+       Mon, 29 Oct 2012 09:31:42 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 9B708431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 29 Oct 2012 09:31:42 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+       by guru.guru-group.fi (Postfix) with ESMTP id 1AD2610007D;\r
+       Mon, 29 Oct 2012 18:31:43 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Michael Stapelberg <michael+nm@stapelberg.de>, notmuch@notmuchmail.org\r
+Subject: Re: [BUG] Saving attachments containing UTF-8 chars\r
+In-Reply-To: <x6sj8xiexi.fsf@midna.zekjur.net>\r
+References: <x6sj8xiexi.fsf@midna.zekjur.net>\r
+User-Agent: Notmuch/0.14+59~gf9031cd (http://notmuchmail.org) Emacs/24.2.1\r
+       (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Mon, 29 Oct 2012 18:31:42 +0200\r
+Message-ID: <m2pq416xzl.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\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: Mon, 29 Oct 2012 16:31:44 -0000\r
+\r
+On Mon, Oct 29 2012, Michael Stapelberg wrote:\r
+\r
+> Hello,\r
+>\r
+> attached you can find a message which seems to trigger a bug somewhere\r
+> in my notmuch setup. The message has been sent to me and includes a\r
+> patchfile, which, when saved using the "w" key in notmuch-emacs, cannot\r
+> be applied.\r
+>\r
+> When using munpack(1) on the raw mail file (I=E2=80=99ve attached rawmail=\r
+.gz\r
+> just to be sure that the message doesn=E2=80=99t get mangled in some way)=\r
+, the\r
+> unpacked attachment can be attached just fine.\r
+>\r
+> When diff'ing both files, I see that munpack correctly stores the file,\r
+> including the problematic UTF-8 apostrophe:\r
+> 00000200  67 3b 20 64 69 64 6e e2  80 99 74 20 72 65 61 64  |g; didn...t =\r
+read|\r
+>\r
+> However, the version of the file saved with notmuch contains:\r
+> 00000200  67 3b 20 64 69 64 6e 19  74 20 72 65 61 64 22 20  |g; didn.t re=\r
+ad" |\r
+>\r
+> If there is anything I can do to help debugging this (or if there is a\r
+> known fix), please let me know.\r
+\r
+I can verify this bug: I copied 'rawmail' to my mail store and attempted\r
+to 'w' the attacment and got the same result (after notmuch new).\r
+\r
+The saving code first does\r
+notmuch show --format=3Draw id:"508953E6.70006@gmail.com"\r
+which decodes OK on command line, and to the buffer when=20\r
+kill-buffer is outcommented in (with-current-notmuch-show-message ...)=20\r
+macro.\r
+\r
+I attempted a set of trial-&-error tricks to get the attachment\r
+saved "correctly", and at least this seems to do the trick:\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index f273eb4..a6a85c0 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -203,9 +203,11 @@ For example, if you wanted to remove an \"unread\" tag=\r
+ and add a\r
+      (let ((id (notmuch-show-get-message-id)))\r
+        (let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*"))))\r
+          (with-current-buffer buf\r
+-          (call-process notmuch-command nil t nil "show" "--format=3Draw" id)\r
+-           ,@body)\r
+-       (kill-buffer buf)))))\r
++         (let ((coding-system-for-read 'no-conversion)\r
++               (coding-system-for-write 'no-conversion))\r
++           (call-process notmuch-command nil t nil "show" "--format=3Draw" id)\r
++           ,@body))))))\r
++%%     (kill-buffer buf)))))\r
+=20\r
+ (defun notmuch-show-turn-on-visual-line-mode ()\r
+   "Enable Visual Line mode."\r
+\r
+---\r
+\r
+(kill-buffer is outcommented above for testing purposes)\r
+\r
+To test this this needs to me evaluated and then the functions\r
+using this macro (notmuch-show-save-attachments  in this case)\r
+\r
+Smart suggestions for proper fix ?\r
+\r
+Tomi\r