From 15b8dc25c9aeef7553c37eec45e071886d339c63 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 10 Feb 2015 18:15:38 +0100 Subject: [PATCH] Re: bug report: Emacs notmuch-mode fails attachments with spaces --- 1c/aa7420959f69b59c0cd911c33a1863e60f1a2c | 166 ++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 1c/aa7420959f69b59c0cd911c33a1863e60f1a2c diff --git a/1c/aa7420959f69b59c0cd911c33a1863e60f1a2c b/1c/aa7420959f69b59c0cd911c33a1863e60f1a2c new file mode 100644 index 000000000..79ceb1cc4 --- /dev/null +++ b/1c/aa7420959f69b59c0cd911c33a1863e60f1a2c @@ -0,0 +1,166 @@ +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 AB422431E62 + for ; Tue, 10 Feb 2015 09:16:01 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 1.738 +X-Spam-Level: * +X-Spam-Status: No, score=1.738 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7] + 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 WdbJwl8Nwlv1 for ; + Tue, 10 Feb 2015 09:15:58 -0800 (PST) +Received: from mail.tiggerswelt.net (mail.tiggerswelt.net [94.186.151.130]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 376F0431FC7 + for ; Tue, 10 Feb 2015 09:15:58 -0800 (PST) +Received: from localhost (f055173025.adsl.alicedsl.de [78.55.173.25]) + (using TLSv1 with cipher AES128-SHA (128/128 bits)) + (No client certificate requested) + by mail.tiggerswelt.net (Postfix) with ESMTP id 3F3615750; + Tue, 10 Feb 2015 18:17:00 +0100 (CET) +From: Nils Dagsson Moskopp +To: Tomi Ollila , notmuch@notmuchmail.org +Subject: Re: bug report: Emacs notmuch-mode fails attachments with spaces +In-Reply-To: +References: <87twyurc78.fsf@dieweltistgarnichtso.net> + +User-Agent: Notmuch/0.18.2 (http://notmuchmail.org) Emacs/23.4.1 + (i486-pc-linux-gnu) +Date: Tue, 10 Feb 2015 18:15:38 +0100 +Message-ID: <8761b9pu11.fsf@dieweltistgarnichtso.net> +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha256; protocol="application/pgp-signature" +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: Tue, 10 Feb 2015 17:16:01 -0000 + +--=-=-= +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable + +Tomi Ollila writes: + +> On Mon, Feb 09 2015, Nils Dagsson Moskopp = + wrote: +> +>> Dear notmuch developers, +>> +>> +>> I use notmuch-mode for GNU Emacs for managing my email. +>> +>> I think I have found a bug in notmuch-mode: If I do =E2=80=9C.-v=E2=80= +=9D on the line =E2=80=9C[ +>> 2015 _ Richtlinien.pdf: application/pdf ]=E2=80=9D, then notmuch will op= +en three +>> windows of zathura (the PDF viewer I use). +>> +>> It seems to me that someone here either forgot quoting or decided to +>> split filenames on spaces. I suggest that =E2=80=9C2015 _ Richtlinien.pd= +f: +>> application/pdf=E2=80=9D should be quoted in notmuch-show-view-part. +>> +>> Note that saving attachment (=E2=80=9C.-s=E2=80=9D, notmuch-show-save-pa= +rt) generally +>> works even if the attachment file names have spaces. In case it matters, +>> I normally use the rc(1) shell in Debian . +> +> This code handles the saving and displaying in question (quick look hop i +> am right :) +> +> 2282 (defun notmuch-show-save-part () +> 2283 "Save the MIME part containing point to a file." +> 2284 (interactive) +> 2285 (notmuch-show-apply-to-current-part-handle #'mm-save-part)) +> 2286=20 +> 2287 (defun notmuch-show-view-part () +> 2288 "View the MIME part containing point in an external viewer." +> 2289 (interactive) +> 2290 ;; Set mm-inlined-types to nil to force an external viewer +> 2291 (let ((mm-inlined-types nil)) +> 2292 (notmuch-show-apply-to-current-part-handle #'mm-display-part)= +)) +> +> SO, there is 2 options: +> +> 1) mm executes save part correctly but not display part + +It seems I cannot investigate this with my knowledge, as =E2=80=9CM-x +find-function RET mm-display-part=E2=80=9D gives =E2=80=9CCan't find library +/usr/share/emacs/23.4/lisp/gnus/mm-decode.el=E2=80=9D. Any ideas? + +> 2) there is (shell) wrapper program executing zathura which cannot handle +> arguments with spaces (there is plenty of examples of this!) +> +> +> You could try to check how th external processes are executed by executin= +g: +> +> strace -f -e trace=3Dprocess emacs -f notmuch +> +> (emacs on X is preferable in this case ;) + +Thank you for that suggestion. It seems that there does happen both some +(wrong) escaping and splitting at spaces. I can see the following trace: + +=2D-- snib --- +execve("/usr/bin/zathura", ["/usr/bin/zathura", "/tmp/emm.23178ut2/2015\\",= + "_\\", "Richtlinien.pdf"] [/* 51 vars */]) =3D 0 +=2D-- snab --- + +Somewhat unusually, it is preceeded by an invocation of the shell: + +=2D-- sneb --- +execve("/usr/bin/rc", ["/usr/bin/rc", "-c", "/usr/bin/zathura /tmp/emm.2317= +8u"...], [/* 51 vars */] +=2D-- snob --- + +It seems to me that all of the following are true in this case: + +1. Emacs executes the user's default shell to start zathura. + +2. For this, Emacs escapes the filename. + +3. Emacs applies the wrong escaping to the filename. Note that single + quotes are interoperable between shells, while backslashes are not. + +4. The rc(1) shell splits on spaces, as it knows no backslash escaping. + +5. The shell executes zathura with three arguments, all bogus filenames. + +I cannot pinpoint where all this is happening, but I would suggest to +just execve() zathura with a single unescaped filename as its argument. + +Greetings, +=2D-=20 +Nils Dagsson Moskopp // erlehmann + + +--=-=-= +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1 + +iF4EAREIAAYFAlTaPLsACgkQZGjbY/Ag5QmGRQEApr9FG6WpfkDUjLxhdGu4DbtG +dIoF/fSqfU4pSUlY7U0A/AoyfkDs8DrdvXekmBfBCGbIf04xv7a7o1CqFCU5EQtq +=hh19 +-----END PGP SIGNATURE----- +--=-=-=-- -- 2.26.2