🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.vm.bug
Article #707

Re: Can't launch attachments with "spaces" in file name

#707
From: Jeffrey J. Kosowsky
Date: Tue, 03 Feb 2004 22:31
86 lines
4772 bytes
Kevin Rodgers <ihs_4664@yahoo.com> writes:
> Jeffrey J. Kosowsky wrote:
>  > Kevin Rodgers <ihs_4664@yahoo.com> writes:
>  >>The file name should not be quoted when it is passed directly to an
>  >>external PROGRAM.  Since the cmd launcher is a shell, you should use the
>  >>COMMAND-LINE syntax provided by vm-mime-external-content-types-alist to
>  >>take advantage of the patch I posted on the 12th in this thread (which
>  >>quotes the file name when it is passed to a shell):
>  >>
>  >>("application" "cmd /c %f")
>  >>("audio" "cmd /c %f")
>  >>("image" "cmd /c %f")
>  >>("video" "cmd /c %f")
>  >
>  > Unfortunately, this does not seem to solve the problem for me. I still
>  > get the same situation where the file is saved to the temp directory
>  > but the application is not launched. Again, the problem is only with
>  > files that have odd characters like '&' in them.
>  >
>  > Note the messages buffer shows the following message:
>  >         Launching cmd /c "c:/DOCUME~1/myname/LOCALS~1/Temp/FP&A 2004-2005
>  >         Capabilities.ppt"... done
>  >
>  > The problem with the '&' is confirmed because when I run the command
>  > directly from the DOS prompt as follows:
>  > C:> cmd /c "c:/DOCUME~1/myname/LOCALS~1/Temp/FP&A 2004-2005 Capabilities.ppt"
>  >
>  > I get the following response:
>  > 'c:/DOCUME~1/myname/LOCALS~1/Temp/FP' is not recognized as an internal
>  > or external command, operable program or batch file.
>  > 'A' is not recognized as an internal or external command,
>  > operable program or batch file.
>  >
>  > So clearly, the ampersand seems to be screwing things up.
>  >
>  > Any suggestions?
> 
> It might be that VM is using the file name that was cached in the MIME
> layout, instead of the quoted file name.  What does this return on your
> platform:
> 
> 	(shell-quote-argument
> 	 "c:/DOCUME~1/myname/LOCALS~1/Temp/FP&A 2004-2005 Capabilities.ppt")
> 

Returns: 
        "c:/DOCUME~1/myname/LOCALS~1/Temp/FP&A 2004-2005 Capabilities.ppt"

> Also, what happens if you leave off the %f spec so that
> vm-mime-display-external-generic adds the quoted name itself:
> 
> 	("application" "cmd /c")
> 	("audio" "cmd /c")
> 	("image" "cmd /c")
> 	("video" "cmd /c")

No change...

However, I have identified the *source* of the problem.
According the the help message generated by "help cmd" in an XP shell,
special characters like '&' need to be *directly* quoted. Specifically,
        The special characters that require quotes are:
             <space>
             &()[]{}^=;!'+,`~

In other words quoting the *entire* file name fails as follows:
        cmd "FP&A 2004-2005 Capabilities.ppt"
gives:
        'FP' is not recognized as an internal or external command,
        operable program or batch file.
        'A.doc' is not recognized as an internal or external command,
        operable program or batch file.

Instead, you need to quote the *special* character itself as follows:
        cmd FP"&"A 2004-2005 Capabilities.ppt
which correctly opens the file.

So, to make this work, you need to quote directly all the special
characters in the string represented by %f.

Not sure how to do this best in elisp though... (Perl on the other
hand would be very easy).

At least, this seems to explain the problem!

Jeff
Technical Details
Message-ID: <m2llnjn6bs.fsf@consult.pretender>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny02.gnilink.net.POSTED!9056c659!not-for-mail
References: <m2fzekj10g.fsf@consult.pretender> <400320B7.5060408@yahoo.com> <m2k73n2nrb.fsf@consult.pretender> <400D5599.10709@yahoo.com> <m2isj6m7a4.fsf@consult.pretender> <861xpth8a1.fsf@robf.deREMOVETHIS> <m2smi88qsy.fsf@consult.pretender> <86hdyoc6n9.fsf@robf.deREMOVETHIS> <m2y8rscb3z.fsf@consult.pretender> <4017E7FE.8040704@yahoo.com> <m21xpjvd3q.fsf@consult.pretender> <401FCD17.6010700@yahoo.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6829,6e83a1235cadfbbe
X-Google-Attributes: gidf6829,public
X-Google-ArrivalTime: 2004-02-03 14:31:21 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny02.gnilink.net.POSTED!9056c659!not-for-mail
Newsgroups: gnu.emacs.vm.bug
Subject: Re: Can't launch attachments with "spaces" in file name
References: <m2fzekj10g.fsf@consult.pretender> <400320B7.5060408@yahoo.com> <m2k73n2nrb.fsf@consult.pretender> <400D5599.10709@yahoo.com> <m2isj6m7a4.fsf@consult.pretender> <861xpth8a1.fsf@robf.deREMOVETHIS> <m2smi88qsy.fsf@consult.pretender> <86hdyoc6n9.fsf@robf.deREMOVETHIS> <m2y8rscb3z.fsf@consult.pretender> <4017E7FE.8040704@yahoo.com> <m21xpjvd3q.fsf@consult.pretender> <401FCD17.6010700@yahoo.com>
From: kosowsky@consult.pretender (Jeffrey J. Kosowsky)
Message-ID: <m2llnjn6bs.fsf@consult.pretender>
Lines: 86
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Date: Tue, 03 Feb 2004 22:31:19 GMT
NNTP-Posting-Host: 141.154.120.29
X-Complaints-To: abuse@verizon.net
X-Trace: nwrdny02.gnilink.net 1075847479 141.154.120.29 (Tue, 03 Feb 2004 17:31:19 EST)
NNTP-Posting-Date: Tue, 03 Feb 2004 17:31:19 EST