From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: [Bug] org-protocol does not kill client process with org-protocol-capture Date: Wed, 25 May 2016 16:28:39 -0500 Message-ID: <87a8jd25fc.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5gMJ-0003TB-FX for emacs-orgmode@gnu.org; Wed, 25 May 2016 17:28:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5gMF-0003T1-AO for emacs-orgmode@gnu.org; Wed, 25 May 2016 17:28:54 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:38036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5gMC-0003R6-UT for emacs-orgmode@gnu.org; Wed, 25 May 2016 17:28:51 -0400 Received: from archbook (wcnat-96-17.wheaton.edu [209.147.96.17]) by mail.messagingengine.com (Postfix) with ESMTPA id B799FCCD26 for ; Wed, 25 May 2016 17:28:39 -0400 (EDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Org Mode I would like to report two bugs in org-protocol. 1. The call to (server-edit) on line 626 of org-protocol.el does not succeed in terminating the server process or signaling to the client to stop waiting for org-protocol-capture (despite the :kill-server property). This can have potentially dangerous side-effects when calling org-protocol from a web browser. On Linux, for instance, if I call org-protocol-capture via a bookmark from Chromium or Firefox and then abort the capture within emacs (with "q" in the capture buffer or with "C-g"), xdg receives an error signal and then tries to send the command to another application. In my case, because of the default xdg settings, this leads to a search being run in firefox that contains the entire org-protocol string (thus raising the possibility of leaking private information to a third-party server). A long time ago (in 2009) server-delete-client was replaced by server-edit (commit 13fe6b1858033eca882c38dd8bc422c0c4c6bb9b): --8<---------------cut here---------------start------------->8--- - (if (plist-get (cdr prolist) :kill-client) - (server-delete-client client t)) + (when (plist-get (cdr prolist) :kill-client) + (message "Greedy org-protocol handler. Killing client.") + (server-edit)) --8<---------------cut here---------------end--------------->8--- Does anyone remember the reason for change? I tried server-delete-client and it succeeds in killing the process and signaling to client to stop waiting. By contrast, server-edit does not successfully kill the process. 2. The condition-case added with commit 25eb14bc2cadab293e200c018284870a1eeb4490 on December 2, 2015 (lines 631-635) causes org-protocol-capture to run twice when the process is aborted, warning one (often incorrectly) to use new-style links. This is because typing "q" in the capture buffer signals an error, which triggers the condition case, leading to the warning and causing org-protocol-capture to be run a second time with the false warning. Here are the steps to replicate these bugs: 1. /usr/bin/emacs -Q -l minimal.el ...where minimal contains the following --8<---------------cut here---------------start------------->8--- (add-to-list 'load-path "~/org-mode/lisp") (add-to-list 'load-path "~/org-mode/contrib/lisp") (require 'org-protocol) (setq org-capture-templates '(("n" "A note" entry (file "~/test.org") "* %a\n %U\n %?\n %i"))) (server-start) --8<---------------cut here---------------end--------------->8--- 2. open a terminal and enter the following: emacsclient "org-protocol://capture?url=3Dhttp://orgmode.org/&title=3DOrg m= ode for Emacs =E2=80=93 Your Life in Plain Text&body=3DTesting" 3. abort the capture process with "q" or C-g What happens: 1. The emacsclient continues to wait. The terminal reads: "Waiting for Emacs..." (Bug #1) Please note that using the "-n" flag with emacsclient will do nothing in this context, since org-protocol is hijacks the server process before the no-wait flag is processed. 2. Upon pressing C-g or q, a warning appears in Emacs ("Please update your org protocol handler to deal with new-style links") and org-capture runs again, requiring a second abort. (Bug #2) 3. emacsclient in the terminal outputs ("*ERROR*: Abort). (Bug #1) What I would expect to happen: When using the capture protocol, emacsclient would not wait and instead would simply exit (because of the :kill-server property in org-protocol-protocol-alist-default). Likewise, aborting a capture process would not send an error message to the client. Thanks, Matt