unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: sbaugh@catern.com
To: Eli Zaretskii <eliz@gnu.org>
Cc: Jim Porter <jporterbugs@gmail.com>,
	sbaugh@janestreet.com, 65902@debbugs.gnu.org
Subject: bug#65902: 29.0.92; emacsclient-mail.desktop fails due to complicated escaping
Date: Thu, 14 Sep 2023 11:03:44 +0000 (UTC)	[thread overview]
Message-ID: <87il8dt3sh.fsf@catern.com> (raw)
In-Reply-To: <83edj1mja5.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Sep 2023 08:10:58 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Wed, 13 Sep 2023 12:33:01 -0700
>> Cc: sbaugh@catern.com, 65902@debbugs.gnu.org
>> From: Jim Porter <jporterbugs@gmail.com>
>> 
>> On 9/13/2023 12:13 PM, Eli Zaretskii wrote:
>> > And I don't understand why we need to add any options to Emacs itself,
>> > btw.  The suggestion to have some "symmetry" here was one of the
>> > reasons that discussion got nowhere.  So let's learn from that
>> > mistake, at least.
>> 
>> There's a practical benefit to this. If you have $EDITOR set in your 
>> environment to something like "emacsclient --alternate-editor=emacs", 
>> then it would be nice if you could say this:
>> 
>>    $EDITOR --apply some-func arg1 arg2
>> 
>> and have it do the same thing whether or not there was already an Emacs 
>> server running. The symmetry between the two commands (plus proper 
>> argument forwarding) would make that work.
>> 
>> However, if people can't agree, then we could probably drop that part. 
>> To me, it sounds like people *do* agree that this would be good to have 
>> though.
>
> People might agree, but I don't.  Please consider the perspective.
> This started as an obscure and rare problem in a desktop file (which
> we provided solely out of good will, since it really isn't our job to
> do so, it's the job of downstream distros).  The proposed solution was
> to add a completely new option to emacsclient, with its own special
> syntax and rules about what can and cannot be done with it.  This is
> already something that should raise brows: how can such an unimportant
> reason cause us to make such significant changes?  We didn't yet
> finish discussing that nor even had time to understand all the
> implications (remember: Lars suggested to support several such
> options, which required another special option), and we already are
> told that "for symmetry" we should add the same to Emacs.  All that
> where just yesterday there was no need for any new options in either,
> and if we decided to drop those desktop files from our sources (which
> I personally am tempted to do every few weeks, due to issues they
> cause us all the time since their introduction), then even the
> original need will miraculously disappear into thin air.

The issue is not really with the desktop file.  It's a generic problem:
Suppose I have some arbitrary data which I want to send to the Emacs
server (in this case, a URI).  Today, there's no easy way to do that.

- One approach is to stick the data inside an --eval call, as
  emacsclient-mail.desktop is doing.  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.  It is currently broken for me.

- Another approach is to do what org-protocol does (shipped with
  Emacs!), and advise server-visit-files (with
  org-protocol-check-filename-for-protocol), and pass the data as a
  string FILE argument to emacsclient which gets intercepted by advice.
  But this is of course a gross hack, and also it still requires
  escaping the data, since some characters will still be specially
  interpreted.  It would be nice to get rid of this org-protocol hack
  which is shipped with Emacs.

- A third approach is to put the data in a temporary file and pass the
  path of that file to emacsclient, then use an --eval to process the
  file.  But this doesn't work when emacsclient and the Emacs server are
  on different hosts or in different environments.

- Finally, a fourth approach is to teach emacsclient to be able to send
  this arbitrary data to Emacs on its own.  Such as by adding --apply.
  There are a bunch of designs for that, but all of them require
  modifying emacsclient.

I have many times before wanted to be able to pass data to Emacs without
worrying about escaping.  This would be a very useful feature to have.
And it would be nice to get rid of the org-protocol hack, and get rid of
the complicated and broken escaping needed for things like
emacsclient-mail.desktop.

> So this is a classic case of the tail wagging the dog.
>
> 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.  This solution is far
simpler, and is reusable for many other different purposes.

> I would in general prefer not to add any new options to our programs
> due to this weak reason.  Once again: it is not our job to get these
> desktop files right in every single downstream environment, so let's
> not make it our problem, certainly not a problem we should solve using
> such non-trivial solutions.

We don't have to add it to Emacs itself.  But it's not just for the
desktop files.  It's a relatively small feature to add to emacsclient,
and it's something that I've heard years of user requests for.

I have many times before wanted to be able to pass data to Emacs without
worrying about escaping.  This would be a very useful feature to have.
It would be nice to get rid of the org-protocol hack, and get rid of the
complicated and broken escaping needed for things like
emacsclient-mail.desktop.





  reply	other threads:[~2023-09-14 11:03 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fe2cc764-86c6-4840-80b7-8f3a3778b374@email.android.com>
2023-09-13 14:50 ` bug#65902: 29.0.92; emacsclient-mail.desktop fails due to complicated escaping Eli Zaretskii
2023-09-13 15:01   ` Andreas Schwab
2023-09-13 15:23   ` Spencer Baugh
2023-09-13 16:19     ` Jim Porter
2023-09-13 19:13     ` Eli Zaretskii
2023-09-13 19:33       ` Jim Porter
2023-09-13 20:00         ` Spencer Baugh
2023-09-13 20:16           ` Jim Porter
2023-09-14  5:10         ` Eli Zaretskii
2023-09-14 11:03           ` sbaugh [this message]
2023-09-14 11:18             ` sbaugh
2023-09-14 11:35             ` sbaugh
2023-09-14 13:36             ` Eli Zaretskii
2023-09-14 14:04               ` Spencer Baugh
2023-09-14 14:31                 ` Eli Zaretskii
2023-09-14 19:16               ` Jim Porter
2023-09-15  5:33                 ` Eli Zaretskii
2023-09-16 13:43           ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-16 14:02             ` Eli Zaretskii
2023-09-16 15:54               ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found] <80d8aeb0-c9f1-410f-b83d-60f83ca5b3af@email.android.com>
2023-09-14 14:57 ` Eli Zaretskii
2023-09-14 15:10   ` Spencer Baugh
2023-09-15  6:29     ` Eli Zaretskii
2023-09-22  1:36       ` sbaugh
2023-09-22  6:36         ` Eli Zaretskii
2023-09-23 20:24           ` sbaugh
2023-09-24  5:18             ` Eli Zaretskii
2023-09-24 14:20               ` sbaugh
2023-10-21 15:20                 ` sbaugh
2023-10-22  5:27                   ` Eli Zaretskii
2023-10-22 14:15                     ` sbaugh
2023-10-22 16:09                       ` Andreas Schwab
2023-10-22 19:53                         ` sbaugh
2023-10-23 16:38                           ` Andreas Schwab
2023-10-23 16:52                           ` Jim Porter
2023-10-24 16:27                             ` sbaugh
2023-10-29 12:20                               ` Eli Zaretskii
2023-10-22  5:39                   ` Jim Porter
2023-09-22  7:05         ` Stefan Kangas
2023-09-22  7:14           ` Eli Zaretskii
2023-09-22  9:29             ` Andreas Schwab
2023-09-22 11:32               ` Eli Zaretskii
2023-09-22 12:37                 ` Andreas Schwab
2023-09-22 12:56                   ` Eli Zaretskii
2023-09-22 13:23                     ` Andreas Schwab
2023-09-22 14:51                       ` Eli Zaretskii
2023-09-22 14:52                         ` Andreas Schwab
2023-09-13  2:24 sbaugh
2023-09-13  2:30 ` sbaugh
2023-09-13  3:46   ` Jim Porter
2023-09-13  8:00     ` Robert Pluim
2023-09-13 13:06       ` Eli Zaretskii
2023-09-13 14:22         ` Robert Pluim
2023-09-13 12:41     ` Eli Zaretskii
2023-09-13 12:57     ` sbaugh
2023-09-13 12:41   ` Eli Zaretskii
2023-09-13 13:01     ` sbaugh
2023-09-13 13:26       ` Eli Zaretskii
2023-09-16 13:30         ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87il8dt3sh.fsf@catern.com \
    --to=sbaugh@catern.com \
    --cc=65902@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jporterbugs@gmail.com \
    --cc=sbaugh@janestreet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).