emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add shell-quasiquote.


From: Eli Zaretskii
Subject: Re: [PATCH] Add shell-quasiquote.
Date: Mon, 19 Oct 2015 08:56:05 +0300

> Cc: address@hidden, address@hidden
> From: Daniel Colascione <address@hidden>
> Date: Sun, 18 Oct 2015 22:19:51 -0700
> 
> On 10/18/2015 10:15 PM, Eli Zaretskii wrote:
> >> Date: Mon, 19 Oct 2015 13:32:51 +0900
> >> From: "Stephen J. Turnbull" <address@hidden>
> >> Cc: Random832 <address@hidden>,
> >>     address@hidden
> >>
> >> Eli Zaretskii writes:
> >>  > Random832 writes:
> >>
> >>  > > Yes, sorry. A typical Windows program (at least, one compiled with
> >>  > > MSVC's setargv.obj) will try to interpret wildcards in any part of
> >>  > > CommandLineToArgv's result which contains a ? or * character, with
> >>  > > no provision to prevent it from doing so. (In particular, double
> >>  > > quotes have no effect).
> >>  > 
> >>  > This actually depends on the startup code.  The latest release of
> >>  > mingw.org's MinGW runtime does allow you to quote wildcard characters.
> >>  > And on Windows XP and older even the other runtimes allow that.
> >>  > 
> >>  > In any case, this is not an Emacs problem.
> >>
> >> Of course it is, in a security context.  I don't think it matters
> >> anywhere near as much as code injection, but if Emacs is built with
> >> one of those runtimes that doesn't allow wildcards to be disabled, its
> >> users will be affected.
> >>
> >> I think it probably can be immediately judged irrelevant (and perhaps
> >> that's what you meant) if Emacs is normally built with a runtime that
> >> doesn't interpret quoted wildcards, and the runtimes that always
> >> interpret wildcards are not supported.
> > 
> > That's a misunderstanding: the runtime in question is the one used
> > with the program that Emacs invokes, not the one used to run Emacs
> > itself.  On MS-Windows, the expansion of wildcards on the command line
> > is done by the application which accepts the command line (in its
> > startup code, before the main function is invoked), so that's what
> > determines whether a quoted "*" will or will not be expanded.  The
> > invoking Emacs cannot control or affect that in any way.
> 
> But maybe we can make the argument-quoting style a particular program
> expects a user-customizable variable.

Unless I misunderstand you, this isn't possible.  Or maybe there's
some subtle trick that I'm not aware of.

Here are the details for those who don't already know them.

There are only 2 styles of quoting used by native Windows programs,
and a 3rd style used by ported Posix shells.  Emacs already supports
the 3rd style automatically (by examining the program it is about to
invoke).  As to the other 2 styles, they are the "cmd style" and the
style of MS runtime's setargv.  The "cmd style" is AFAIK supported
only by cmd itself and compatible shells, which leaves us with the
setargv style.

The problem which started this sub-thread is that Microsoft changed
the behavior of setargv, which lives in the system shared library
every C program links against, starting with Windows Vista (or maybe
Windows 7, I never used Vista).  Before the change, quoting a wildcard
"like this" would disable its globbing; after the change, quoted
wildcards are globbed regardless, and there's no alternative way of
protecting wildcards from globbing, AFAIK, except make your program
avoid calling setargv, and instead call your own globbing function
(which is what the latest MinGW runtime does).

The upshot of this is that a program will behave differently depending
on the Windows version it runs on, unless it was linked with the
latest MinGW runtime.

So given all this mess, how would you suggest to allow customization
of the wildcard quoting?

(Btw, in general, I'd prefer Emacs to DTRT by default, without asking
the user to customize anything.  If possible, of course.)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]