From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1 with LMTPS id +FvEGe0kil7YCAAAk0OIDg (envelope-from ) for ; Sun, 05 Apr 2020 18:35:25 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id yJVnNeskil5/YAAAB5/wlQ (envelope-from ) for ; Sun, 05 Apr 2020 18:35:23 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id 25312683170 for ; Sun, 5 Apr 2020 16:59:59 +0000 (UTC) Received: from localhost ([::1]:50116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jL8cm-0000Co-Sm for larch@yhetil.org; Sun, 05 Apr 2020 12:59:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58153) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jL5lk-0000fF-28 for emacs-orgmode@gnu.org; Sun, 05 Apr 2020 09:57:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jL5li-0007j5-5s for emacs-orgmode@gnu.org; Sun, 05 Apr 2020 09:56:59 -0400 Received: from pie.tf ([62.75.142.128]:58564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jL5lf-0007cg-8O for emacs-orgmode@gnu.org; Sun, 05 Apr 2020 09:56:58 -0400 Received: from [185.197.132.141] (helo=localhost) by pie.tf with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1jL5lc-0003ZR-90 for emacs-orgmode@gnu.org; Sun, 05 Apr 2020 13:56:52 +0000 From: Ferdinand Pieper To: emacs-orgmode@gnu.org Subject: Additonal slashes in URI sent to org-protocol Date: Sun, 05 Apr 2020 15:56:51 +0200 Message-ID: <871rp29gt8.fsf@pie.tf> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 62.75.142.128 X-Mailman-Approved-At: Sun, 05 Apr 2020 12:59:25 -0400 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=default; t=1586105999; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=LkH18yb6yfawUdNM9yjkPf0jLdm323OW9huG8wgYR1g=; b=EI6r43wxzwWguX7hIX0Ts8W55mX7svDiv7XGNEn0s5NjvssEtXbpzSUIuzkEGnIGyp8KIi e/XWW0e67BcZXez9FxJD2xkdbFG7GXst0FOO6kF7FFbl8emF4soje4rK5Mk0liZ2b3kP8x 8h7yaiZZfn5kKmV6YFLzyIsOhgFJkyo= ARC-Seal: i=1; s=default; d=yhetil.org; t=1586105999; a=rsa-sha256; cv=none; b=tnV6gobGehuVRnnHR35kQrnaMZlmSBAaT/rDS97FNpiEKECTvyGememB1k2kQVHhZfqbry CiSlPN+7U09XCL9s5bLokIO1HRz14pLjdl+gyWl5K80IlBrjL1iKNENvI6xSTAGJARM5f9 Vd1bvYvNayksgFC9JZc4AUSZ1rOcXdY= ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=none; spf=pass (aspmx2.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scanner: scn0 X-Spam-Score: -1.01 Authentication-Results: aspmx2.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx2.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.01 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.58546568180245]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.33), country: US(-0.01), ip: 209.51.188.17(-0.59)]; TO_DN_NONE(0.00)[]; ARC_SIGNED(0.00)[i=1]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[fer@pie.tf,emacs-orgmode-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; MIME_TRACE(0.00)[0:+,1:+,2:+]; DMARC_NA(0.00)[pie.tf]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: 3vgFxJnFyIuC --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi everyone, I was trying to set up org-protocol with Firefox (version 74.0) running und= er Windows 10. Unfortunately there seems to be an issue with additional sla= shes added to the URI so org-protocol can not parse it. I setup a bookmark as mentioned in [1]. I changed the bookmark content to t= he new style of org-protocol links as described in [2], resulting in: --8<---------------cut here---------------start------------->8--- javascript:location.href=3D'org-protocol://capture?template=3DL&url=3D'+enc= odeURIComponent(location.href)+'&title=3D'+encodeURIComponent(document.titl= e)+'&body=3D'+encodeURIComponent(window.getSelection()) --8<---------------cut here---------------end--------------->8--- To setup the forwarding to Emacs running inside WSL I used a registry entry= as described on the same page: --8<---------------cut here---------------start------------->8--- REGEDIT4 [HKEY_CLASSES_ROOT\org-protocol] @=3D"URL:Org Protocol" "URL Protocol"=3D"" [HKEY_CLASSES_ROOT\org-protocol\shell] [HKEY_CLASSES_ROOT\org-protocol\shell\open] [HKEY_CLASSES_ROOT\org-protocol\shell\open\command] @=3D"\"C:\\Windows\\System32\\wsl.exe\" emacsclient \"%1\"" --8<---------------cut here---------------end--------------->8--- Somehow Firefox adds another slash inbetween ~capture~ and the questionmark= , so that Emacs receives this call, which I extracted from a Backtrace: --8<---------------cut here---------------start------------->8--- * org-protocol-check-filename-for-protocol("/mnt/c/Windows/system32/org-pro= tocol:/capture/?template=3DL&url=3Dhttps%3A%2F%2Forgmode.org%2F&title=3DOrg= %20mode%20for%20Emacs%20=E2=80=93%20Your%20Life%20in%20Plain%20Text&body=3D= " (("/mnt/c/Windows/system32/org-protocol:/capture/?template=3DL&url=3Dhttp= s%3A%2F%2Forgmode.org%2F&title=3DOrg%20mode%20for%20Emacs%20=E2=80=93%20You= r%20Life%20in%20Plain%20Text&body=3D")) #>) --8<---------------cut here---------------end--------------->8--- The format ~org-protocol:/capture/?template=3DL...~ still seems to be withi= n the HTML spec. But the additional slash makes the function ~org-protocol-= check-filename-for-protocol~ fail to recognize the URI as a capture call. S= ee also the discussion in [3]. I also tried the same bookmark in Chromium (version 83.0) but it also adds = the additional slash. I attached a proposed patch to allow URIs with and without the slash. I'd be happy to know if anybody has a working setup using the bookmark abov= e or similar or if there are other solutions which do not require this patc= h. Otherwise please let me know what is left to do to get this patch applie= d. Thanks! Footnotes: [1] https://orgmode.org/worg/org-contrib/org-protocol.html#org120a44e [2] https://orgmode.org/Changes_old.html#org18864d9 [3] https://github.com/sprig/org-capture-extension/issues/41#issuecomment-5= 78499266 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-protocol-Allow-slashes-after-sub-protocol.patch >From a476821ebecd9649b2c88a86a0562c757bb2c3a0 Mon Sep 17 00:00:00 2001 From: fpi Date: Fri, 3 Apr 2020 19:12:01 +0200 Subject: [PATCH] org-protocol: Allow slashes after sub-protocol This change lets org-protocol handle URIs with additional slashes before the start of the query string, e.g. org-protocol:/capture/?template=... instead of org-protocol:/capture?template=... --- lisp/org-protocol.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el index 55a534d0d..8fbff9611 100644 --- a/lisp/org-protocol.el +++ b/lisp/org-protocol.el @@ -617,13 +617,13 @@ CLIENT is ignored." (let ((proto (concat the-protocol (regexp-quote (plist-get (cdr prolist) :protocol)) - "\\(:/+\\|\\?\\)"))) + "\\(:/+\\|/*\\?\\)"))) (when (string-match proto fname) (let* ((func (plist-get (cdr prolist) :function)) (greedy (plist-get (cdr prolist) :greedy)) (split (split-string fname proto)) (result (if greedy restoffiles (cadr split))) - (new-style (string= (match-string 1 fname) "?"))) + (new-style (string-match (match-string 1 fname) "/*?"))) (when (plist-get (cdr prolist) :kill-client) (message "Greedy org-protocol handler. Killing client.") (server-edit)) -- 2.25.0 --=-=-=--