Your message dated Sat, 26 Apr 2014 12:56:17 +0900
with message-id <[email protected]>
and subject line Re: Bug#745141: mime-support: update-mime should quote 
arguments when converting desktop entries
has caused the Debian Bug report #745141,
regarding mime-support: update-mime should quote arguments when converting 
desktop entries
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
745141: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=745141
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: mime-support
Version: 3.54
Severity: important

When update-mime converts desktop entries from /usr/share/applications into 
mailcap entries, it does not properly quote arguments. I ran into this problem 
when trying to display an image with a space in its filename using run-mailcap. 
I have imagemagick installed, so the relevant mailcap entries, in the 
repeatable order generated by update-mime, are:

image/jpeg; /usr/bin/display.im6 %s; test=test -n "$DISPLAY"
image/jpeg; display.im6 'jpeg:%s'; test=test -n "$DISPLAY"

The first entry, which is what ends up being used as it's listed first, fails 
with a typical "file not found" error with a path truncated at the location of 
the first space, as the mailcap entry needs to quote the "%s" portion of the 
commands to ensure that space-containing filenames are passed as a single 
argument. The second entry succeeds because the "%s" is quoted. The first entry 
is converted from the Exec line in /usr/share/applications/display.im6.desktop, 
"Exec=/usr/bin/display.im6 %f". The second entry is obtained from 
/usr/lib/mime/packages/imagemagick. After installing mirage, I now have another 
mailcap entry converted from a desktop entry, and it has exactly the same 
error, so this is not specific to imagemagick. ("Exec=mirage %f" is converted 
to "image/jpeg; mirage %s; test=test -n "$DISPLAY"")

I am not familiar enough with Perl to provide a patch, but I can tell where 
this is happening in update-mime, and it seems like an easy fix for someone 
confident in their Perl ability. I believe the relevant lines are under "sub 
ReadDesktopEntries", in the block beginning "elsif (m/Exec=(.*)$/i) {".


-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (800, 'testing'), (700, 'unstable'), (600, 'stable'), (500, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

mime-support depends on no packages.

Versions of packages mime-support recommends:
ii  file  1:5.14-2

mime-support suggests no packages.

-- no debconf information

-- 
Joseph Spiros
[email protected]
+1 (440) 707-6855

--- End Message ---
--- Begin Message ---
notfound 745141 3.54
notfound 745141 3.55~experimental1
thanks

Le Fri, Apr 18, 2014 at 03:37:09PM +0200, Philipp Matthias Hahn a écrit :
> 
> The mailcap RFC <http://www.faqs.org/rfcs/rfc1524.html> does not mention
> any quoting rule for %s, but specifies the following:
> > On a UNIX system, such commands will each be a full shell command
> > line, including the path name for a program and its arguments.
> > (Because of differences in shells and the implementation and behavior
> > of the same shell from one system to another, it is specified that the
> > command line be intended as input to the Bourne shell, i.e., that it
> > is implicitly preceded by "/bin/sh -c " on the command line.)
> 
> Considering that there are two quoting formats in shell, a program using
> mailcap would still need to know how to correctly pass the filename:
> - if singe quotes are used, a single quote in the file name itself would
>   need to be encoded as '\''.
> - if double quotes are used, a double quote, dollar sign and back-ticks
>   would still needed to be escaped.
> As such only the calling application can do it right and properly escape
> the filename itself for shell use and only then replace the %s with
> that.
> 
> So I'm all for not putting quotes in the mailcap file itself but put the
> burden on those programs using it.

Dear Philipp and Joseph,

thank you for your inputs.

I fully agree with Philipp's analysis and will keep update-mime's current
behaviour.

Have a nice week-end,

-- 
Charles Plessy
Tsurumi, Kanagawa, Japan

--- End Message ---

Reply via email to