Gnus development mailing list
 help / color / mirror / Atom feed
From: Hrvoje Niksic <hniksic@xemacs.org>
Cc: hniksic@xemacs.org
Subject: [patch] Fix displaying attachments with spaces etc.
Date: Tue, 13 Aug 2002 18:02:59 +0200	[thread overview]
Message-ID: <sxsptwmycek.fsf@florida.munich.redhat.com> (raw)

For years now it has annoyed me that Gnus can't seem to show
attachments whose file name contain spaces.  It was all the weirder
because Gnus does try to dilligently quote file names.  Today I
tracked down the problem.

My Debian system tries to be smart and has system mailcap entries that
look like this:

    image/jpeg; display '%s'

Gnus also tries to be smart and change every occurrence of %s to a
shell-quoted string.  This is presumably so that simple-minded entries
like this:

    image/jpeg; display %s

keep working.  So for the file name "Amateur Pussy(37).jpg" Gnus ends
up calling the display command like this:

    (start-process ... "sh" "-c" "display 'Amateur\\ Pussy\\(37\\).jpg'")

which fails for obvious reasons.  This is annoying because once in a
while I receive a spam that I actually want to read.  (The above
example is, of course, completely fabricated with no connection
whatsoever to real events or spams.)

Here is a fix that special-cases '%s' and "%s" by simply treating them
the same as %s.  This workaround will fail to perform in more
convoluted cases such as display 'foo%sbar', but we won't be any worse
off than we were without it.  I haven't found any use of %s other than
as a complete string in my 271-line system mailcap file.

Here is the patch which I intend to commit unless someone yells
(please Cc me) or offers a better one:

2002-08-13  Hrvoje Niksic  <hniksic@xemacs.org>

	* mm-decode.el (mm-mailcap-command): Remove the quotes around '%s'
	and "%s" so we don't overquote them.

--- lisp/mm-decode.el.orig	Tue Aug 13 17:41:02 2002
+++ lisp/mm-decode.el	Tue Aug 13 17:44:40 2002
@@ -774,7 +774,7 @@
 	(beg 0)
 	(uses-stdin t)
 	out sub total)
-    (while (string-match "%{\\([^}]+\\)}\\|%s\\|%t\\|%%" method beg)
+    (while (string-match "%{\\([^}]+\\)}\\|'%s'\\|\"%s\"\\|%s\\|%t\\|%%" method beg)
       (push (substring method beg (match-beginning 0)) out)
       (setq beg (match-end 0)
 	    total (match-string 0 method)
@@ -782,7 +782,10 @@
       (cond
        ((string= total "%%")
 	(push "%" out))
-       ((string= total "%s")
+       ((or (string= total "%s")
+	    ;; we do our own quoting
+	    (string= total "'%s'")
+	    (string= total "\"%s\""))
 	(setq uses-stdin nil)
 	(push (mm-quote-arg
 	       (gnus-map-function mm-path-name-rewrite-functions file)) out))



             reply	other threads:[~2002-08-13 16:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-13 16:02 Hrvoje Niksic [this message]
2002-08-13 18:28 ` Simon Josefsson
2002-08-13 18:45   ` Alan Shutko
2002-08-13 19:33     ` Simon Josefsson
2002-08-13 18:45   ` Hrvoje Niksic
2002-08-13 18:47   ` Paul Jarc
2002-08-15 12:47     ` Toby Speight
2002-08-15 14:02       ` Simon Josefsson
2002-08-18 19:30       ` Kai Großjohann
2002-08-19 15:49         ` Toby Speight
2002-08-19 15:54           ` list copies (was Re: Fix displaying attachments with spaces etc.) Sean Neakums
2002-08-19 16:04             ` list copies Toby Speight
2002-08-13 18:52   ` [patch] Fix displaying attachments with spaces etc Björn Torkelsson
2002-12-29 22:50 ` Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sxsptwmycek.fsf@florida.munich.redhat.com \
    --to=hniksic@xemacs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).