Subject: bug#65902: 29.0.92; emacsclient-mail.desktop fails due to complicated escaping

From: Eli Zaretskii <[email-masked]>
Date: Thu, 14 Sep 2023 16:36:06 +0300

> From: [email-masked]
> Date: Thu, 14 Sep 2023 11:03:44 +0000 (UTC)
> Cc: Jim Porter <[email-masked]>, [email-masked],
> 	[email-masked]
> 
> The issue is not really with the desktop file.  It's a generic problem:

No, it isn't.  If it were, we'd have heard about it much sooner, and
not because of the desktop files.

What you are doing is representing a rare problem related to a niche
feature is if it were a general one, by inventing use cases to justify
that.  But if those use cases were important, people would have asked
for them long ago.  They didn't.  Why? because --eval already exists.

> > What about alternative solutions: use a shell script in the desktop
> > files, and delegate to that script to solve the problem with quoting?
> > Had anyone considered this strategy?  If not, why not?
> 
> Getting the quoting right is hard and complex, and even Emacs developers
> have failed at it over multiple iterations, and when they fail it either
> breaks or exposes a security vulnerability.

Emacs developers make mistakes even in the simple regexps we have in
our code.  That doesn't mean we should abandon regexps.  The solution
for sending Lisp forms to the server exists, and the quoting, although
tricky in some cases, is not rocket science to get right.  I don't see
why we would need another mechanism to do something similar with
radically different syntax, a separate set of rules and restrictions
that need to be documented, etc. etc.

> This solution is far simpler

That's an illusion.  There's nothing simple about it.  You are
inventing a new mechanism for passing Lisp forms as something other
than Lisp.  This has got to have issues into which we will bump sooner
or later.  E.g., assume that two or more of the arguments to the
function begins with single quote, as in

  $ emacsclient --apply func arg1 'foo arg2 'bar

Escape-quoting, here we come again!