From: Tomi Ollila Date: Mon, 29 Oct 2012 16:31:42 +0000 (+0200) Subject: Re: [BUG] Saving attachments containing UTF-8 chars X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=f15b870c71b8533c9e0dcbd3ce65a6f35446a72b;p=notmuch-archives.git Re: [BUG] Saving attachments containing UTF-8 chars --- diff --git a/9c/c0f67353e662a637f0f438a3375e94434963f1 b/9c/c0f67353e662a637f0f438a3375e94434963f1 new file mode 100644 index 000000000..d6fdf3bcd --- /dev/null +++ b/9c/c0f67353e662a637f0f438a3375e94434963f1 @@ -0,0 +1,121 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id CA658431FBC + for ; Mon, 29 Oct 2012 09:31:43 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id Z8F+0eZ34C1w for ; + Mon, 29 Oct 2012 09:31:42 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 9B708431FAF + for ; Mon, 29 Oct 2012 09:31:42 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 1AD2610007D; + Mon, 29 Oct 2012 18:31:43 +0200 (EET) +From: Tomi Ollila +To: Michael Stapelberg , notmuch@notmuchmail.org +Subject: Re: [BUG] Saving attachments containing UTF-8 chars +In-Reply-To: +References: +User-Agent: Notmuch/0.14+59~gf9031cd (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 29 Oct 2012 16:31:44 -0000 + +On Mon, Oct 29 2012, Michael Stapelberg wrote: + +> Hello, +> +> attached you can find a message which seems to trigger a bug somewhere +> in my notmuch setup. The message has been sent to me and includes a +> patchfile, which, when saved using the "w" key in notmuch-emacs, cannot +> be applied. +> +> When using munpack(1) on the raw mail file (I=E2=80=99ve attached rawmail= +.gz +> just to be sure that the message doesn=E2=80=99t get mangled in some way)= +, the +> unpacked attachment can be attached just fine. +> +> When diff'ing both files, I see that munpack correctly stores the file, +> including the problematic UTF-8 apostrophe: +> 00000200 67 3b 20 64 69 64 6e e2 80 99 74 20 72 65 61 64 |g; didn...t = +read| +> +> However, the version of the file saved with notmuch contains: +> 00000200 67 3b 20 64 69 64 6e 19 74 20 72 65 61 64 22 20 |g; didn.t re= +ad" | +> +> If there is anything I can do to help debugging this (or if there is a +> known fix), please let me know. + +I can verify this bug: I copied 'rawmail' to my mail store and attempted +to 'w' the attacment and got the same result (after notmuch new). + +The saving code first does +notmuch show --format=3Draw id:"508953E6.70006@gmail.com" +which decodes OK on command line, and to the buffer when=20 +kill-buffer is outcommented in (with-current-notmuch-show-message ...)=20 +macro. + +I attempted a set of trial-&-error tricks to get the attachment +saved "correctly", and at least this seems to do the trick: + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index f273eb4..a6a85c0 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -203,9 +203,11 @@ For example, if you wanted to remove an \"unread\" tag= + and add a + (let ((id (notmuch-show-get-message-id))) + (let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*")))) + (with-current-buffer buf +- (call-process notmuch-command nil t nil "show" "--format=3Draw" id) +- ,@body) +- (kill-buffer buf))))) ++ (let ((coding-system-for-read 'no-conversion) ++ (coding-system-for-write 'no-conversion)) ++ (call-process notmuch-command nil t nil "show" "--format=3Draw" id) ++ ,@body)))))) ++%% (kill-buffer buf))))) +=20 + (defun notmuch-show-turn-on-visual-line-mode () + "Enable Visual Line mode." + +--- + +(kill-buffer is outcommented above for testing purposes) + +To test this this needs to me evaluated and then the functions +using this macro (notmuch-show-save-attachments in this case) + +Smart suggestions for proper fix ? + +Tomi