From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: sbaugh@catern.com Newsgroups: gmane.emacs.bugs Subject: bug#65902: 29.0.92; emacsclient-mail.desktop fails due to complicated escaping Date: Thu, 14 Sep 2023 11:03:44 +0000 (UTC) Message-ID: <87il8dt3sh.fsf@catern.com> References: <83ttrym8jx.fsf@gnu.org> <83led9nay9.fsf@gnu.org> <66a6c09e-3b61-d913-5638-4c804fb826f6@gmail.com> <83edj1mja5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7634"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Jim Porter , sbaugh@janestreet.com, 65902@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 14 13:05:33 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qgkA8-0001Xp-0o for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Sep 2023 13:05:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgk9b-0006ob-Mt; Thu, 14 Sep 2023 07:04:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgk9Z-0006nr-Cw for bug-gnu-emacs@gnu.org; Thu, 14 Sep 2023 07:04:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgk9Z-0004DQ-40 for bug-gnu-emacs@gnu.org; Thu, 14 Sep 2023 07:04:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgk9e-0005Fh-F8 for bug-gnu-emacs@gnu.org; Thu, 14 Sep 2023 07:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Sep 2023 11:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65902-submit@debbugs.gnu.org id=B65902.169468944420109 (code B ref 65902); Thu, 14 Sep 2023 11:05:02 +0000 Original-Received: (at 65902) by debbugs.gnu.org; 14 Sep 2023 11:04:04 +0000 Original-Received: from localhost ([127.0.0.1]:37802 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgk8e-0005Dv-Ho for submit@debbugs.gnu.org; Thu, 14 Sep 2023 07:04:04 -0400 Original-Received: from s.wfbtzhsw.outbound-mail.sendgrid.net ([159.183.224.105]:58788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgk8b-0005Dg-1y for 65902@debbugs.gnu.org; Thu, 14 Sep 2023 07:03:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=MMnER4WM7dnXJgyHkY+X3lFDYF0U24d2qdrXMdVSwtY=; b=ukLZIifqYcfpG1kXwCW456QXkubEJcKhU5QgSDfSZ5fXFyS40x8YOVs2u7YOKJoMvfk4 0xy3MKu3s+1ZuCs1TkdYc2owkSl3a7Da9gGm6984stBXL6BYGZjBLQrHkaQ+Hax9N5SPxJ xPLPei98bsvld5TYmmwiyxtJwy5/QL2bHKk4rJoEpyNXu11dAbtBqlyonPj1XC8CDBLveG butM2P5CCzQ6nrA09K6DymlhgRNdBie0uPLfjkH+BfdnMhpYWTx7iPH6pK94Im3ypCyAFn ks9b9zTl2VqNP1lEsBkW5bsX6BSPok0rvWwA8Th/cR1kqxuSCj4xsOlEUXVYBBEw== Original-Received: by filterdrecv-84b96456cb-zd4xh with SMTP id filterdrecv-84b96456cb-zd4xh-1-6502E890-A 2023-09-14 11:03:44.135318015 +0000 UTC m=+10927530.760105120 Original-Received: from earth.catern.com (unknown) by geopod-ismtpd-22 (SG) with ESMTP id 2nl0BncCS_m_-Lgammhxgw Thu, 14 Sep 2023 11:03:43.397 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gnu.org Original-Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 4966765674; Thu, 14 Sep 2023 07:03:42 -0400 (EDT) In-Reply-To: <83edj1mja5.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Sep 2023 08:10:58 +0300") X-SG-EID: ZgbRq7gjGrt0q/Pjvxk7wM0yQFRdOkTJAtEbkjCkHbIOnyHASvNJhhaui0lq+6SDln5iM21jX0qMLrjCdMDzaMx3kRWoX454Ec+ZBIgTEvQv++Cw7ZGLOUVByNR93IR+9CTHrZfiX00bQtUSzKNiP0Ha5qT12trxFRvSADc3HaddLNBtnJ+vdMkAEn5/nQddynAW9msIx0HiGUk85SHJzw== X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270411 Archived-At: Eli Zaretskii writes: >> Date: Wed, 13 Sep 2023 12:33:01 -0700 >> Cc: sbaugh@catern.com, 65902@debbugs.gnu.org >> From: Jim Porter >> >> 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.