Gnus development mailing list
 help / color / mirror / Atom feed
* [patch] Fix displaying attachments with spaces etc.
@ 2002-08-13 16:02 Hrvoje Niksic
  2002-08-13 18:28 ` Simon Josefsson
  2002-12-29 22:50 ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 14+ messages in thread
From: Hrvoje Niksic @ 2002-08-13 16:02 UTC (permalink / raw)
  Cc: hniksic

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))



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2002-12-29 22:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-13 16:02 [patch] Fix displaying attachments with spaces etc Hrvoje Niksic
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

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).