From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mario Martelli Subject: [PATCH] org-protocol: fixes open-source and extends rewriting of URLs Date: Sun, 25 Jun 2017 08:49:34 +0200 Message-ID: <4427263B-5534-4FFD-AFA0-211EDA489001@schnuddelhuddel.de> References: <68E12968-9AF5-440A-B22C-AC55B70BA910@schnuddelhuddel.de> <87k248b6p8.fsf@nicolasgoaziou.fr> <7C76EDC3-CC7E-4AFE-B45B-867752C1B33A@schnuddelhuddel.de> <87a8519rlg.fsf@nicolasgoaziou.fr> <8760fp9mui.fsf@nicolasgoaziou.fr> <2FAD7DF2-2A0C-4703-A383-BA8D3346C691@schnuddelhuddel.de> <18D83D3C-C472-4614-988F-1F1DA5EB5CEC@schnuddelhuddel.de> <87efub7psj.fsf@nicolasgoaziou.fr> <8CE2CFE3-2911-4369-8E93-E80CD25FD7E4@schnuddelhuddel.de> <5442AC7A-D45E-46FE-A3A7-3AB25679B3FE@schnuddelhuddel.de> Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_9F035040-A060-4830-BEF9-E2C5903ED201" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dP1Mf-0003XB-1K for emacs-orgmode@gnu.org; Sun, 25 Jun 2017 02:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dP1Ma-0002fb-Cx for emacs-orgmode@gnu.org; Sun, 25 Jun 2017 02:49:45 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:35686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dP1Ma-0002eq-0u for emacs-orgmode@gnu.org; Sun, 25 Jun 2017 02:49:40 -0400 Received: by mail-wr0-x233.google.com with SMTP id k67so113145516wrc.2 for ; Sat, 24 Jun 2017 23:49:38 -0700 (PDT) Received: from [172.16.0.18] ([78.129.221.30]) by smtp.gmail.com with ESMTPSA id a18sm3690946edd.23.2017.06.24.23.49.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Jun 2017 23:49:36 -0700 (PDT) In-Reply-To: <5442AC7A-D45E-46FE-A3A7-3AB25679B3FE@schnuddelhuddel.de> 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: emacs-orgmode@gnu.org --Apple-Mail=_9F035040-A060-4830-BEF9-E2C5903ED201 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi list, Doing the tests for the documentation I encountered some issues with = org-protocol. [0001-url-is-sanitized-before-processing] I=E2=80=99ve got trouble to get sub-protocol =E2=80=9Copen-source=E2=80=9D= working in some cases. By sanitising the URL it works for me in all = cases. [0002-tests-open-source-uri-against-uri-and-not-filename] This changes the test of the URI which was tested against the resulting = filename. It=E2=80=99s now tested against the base-url. I=E2=80=99m still unsure with this because the code is there for more = than seven years. Maybe I=E2=80=99m not seeing something obvious here. = But all tests I made so far are succeeding with this change. [0003-org-protocol-open-source-can-open-hugo-sources-with-date-url] Enables =E2=80=9Copen-source=E2=80=9D to open hugo sources from a blog = which is using date URLs like: https://cool-blog.com/2017/05/20/cool-post/ = WDYT of this? Kind regards Mario =E2=80=94=20 --Apple-Mail=_9F035040-A060-4830-BEF9-E2C5903ED201 Content-Type: multipart/mixed; boundary="Apple-Mail=_CBEAFE06-A1B0-4522-A13D-D7FCB9E6E8B0" --Apple-Mail=_CBEAFE06-A1B0-4522-A13D-D7FCB9E6E8B0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Hi list,

Doing the tests for the documentation I = encountered some issues with org-protocol.

[0001-url-is-sanitized-before-processing]
I=E2=80=99ve got trouble to get = sub-protocol =E2=80=9Copen-source=E2=80=9D working in some cases. By = sanitising the URL it works for me in all cases.

= --Apple-Mail=_CBEAFE06-A1B0-4522-A13D-D7FCB9E6E8B0 Content-Disposition: attachment; filename=0001-url-is-sanitized-before-processing.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-url-is-sanitized-before-processing.patch" Content-Transfer-Encoding: quoted-printable =46rom=20572a9fb03b62aa989752104898318096fa8809e4=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Mario=20Martelli=20=0A= Date:=20Fri,=2023=20Jun=202017=2018:32:49=20+0200=0ASubject:=20[PATCH=20= 1/3]=20url=20is=20sanitized=20before=20processing=0A=0A---=0A=20= lisp/org-protocol.el=20|=202=20+-=0A=201=20file=20changed,=201=20= insertion(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/lisp/org-protocol.el=20b/lisp/org-protocol.el=0Aindex=20= 825435674..7e986a9ed=20100644=0A---=20a/lisp/org-protocol.el=0A+++=20= b/lisp/org-protocol.el=0A@@=20-520,7=20+520,7=20@@=20The=20location=20= for=20a=20browser's=20bookmark=20should=20look=20like=20this:=0A=20=20=20= ;;=20As=20we=20enter=20this=20function=20for=20a=20match=20on=20our=20= protocol,=20the=20return=20value=0A=20=20=20;;=20defaults=20to=20nil.=0A=20= =20=20(let=20((result=20nil)=0A-=20=20=20=20=20=20=20=20(f=20(plist-get=20= (org-protocol-parse-parameters=20fname=20nil=20'(:url))=20:url)))=0A+=09= (f=20(org-protocol-sanitize-uri=20(plist-get=20= (org-protocol-parse-parameters=20fname=20nil=20'(:url))=20:url))))=0A=20=20= =20=20=20(catch=20'result=0A=20=20=20=20=20=20=20(dolist=20(prolist=20= org-protocol-project-alist)=0A=20=20=20=20=20=20=20=20=20(let*=20= ((base-url=20(plist-get=20(cdr=20prolist)=20:base-url))=0A--=20=0A2.11.0=20= (Apple=20Git-81)=0A=0A= --Apple-Mail=_CBEAFE06-A1B0-4522-A13D-D7FCB9E6E8B0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

[0002-tests-open-source-uri-against-uri-and-not-filename]
=
This changes the test of the URI which = was tested against the resulting filename. It=E2=80=99s now tested = against the base-url.

I=E2=80=99m still unsure with this = because the code is there for more than seven years. Maybe I=E2=80=99m = not seeing something obvious here. But all tests I made so far are = succeeding with this change.

= --Apple-Mail=_CBEAFE06-A1B0-4522-A13D-D7FCB9E6E8B0 Content-Disposition: attachment; filename=0002-tests-open-source-uri-against-uri-and-not-filename.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0002-tests-open-source-uri-against-uri-and-not-filename.patch" Content-Transfer-Encoding: quoted-printable =46rom=20f7562e781de0331231d5e369280a2f710c240ca4=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Mario=20Martelli=20=0A= Date:=20Sat,=2024=20Jun=202017=2016:01:20=20+0200=0ASubject:=20[PATCH=20= 2/3]=20tests=20open-source=20uri=20against=20uri=20and=20not=20filename=0A= =0A---=0A=20lisp/org-protocol.el=20|=202=20+-=0A=201=20file=20changed,=20= 1=20insertion(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/lisp/org-protocol.el=20b/lisp/org-protocol.el=0Aindex=20= 7e986a9ed..6744fc0ac=20100644=0A---=20a/lisp/org-protocol.el=0A+++=20= b/lisp/org-protocol.el=0A@@=20-554,7=20+554,7=20@@=20The=20location=20= for=20a=20browser's=20bookmark=20should=20look=20like=20this:=0A=20=09=09= =20=20=20=20=20=20;;=20Try=20to=20match=20a=20rewritten=20URL=20and=20= map=20it=20to=0A=20=09=09=20=20=20=20=20=20;;=20a=20real=20file.=20=20= Compare=20redirects=20without=0A=20=09=09=20=20=20=20=20=20;;=20suffix.=0A= -=09=09=20=20=20=20=20=20(when=20(string-match-p=20(car=20rewrite)=20f2)=0A= +=09=09=20=20=20=20=20=20(when=20(string-match-p=20(car=20rewrite)=20f1)=0A= =20=09=09=09(throw=20'result=20(concat=20wdir=20(cdr=20rewrite))))))))=0A= =20=09=20=20=20=20=20=20;;=20--=20end=20of=20redirects=20--=0A=20=0A--=20= =0A2.11.0=20(Apple=20Git-81)=0A=0A= --Apple-Mail=_CBEAFE06-A1B0-4522-A13D-D7FCB9E6E8B0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

[0003-org-protocol-open-source-can-open-hugo-sources-with-date-= url]

Enables =E2=80=9Copen-source=E2=80=9D to open hugo sources = from a blog which is using date URLs like:




WDYT of this?

Kind regards
Mario
=E2=80=94 

= --Apple-Mail=_CBEAFE06-A1B0-4522-A13D-D7FCB9E6E8B0-- --Apple-Mail=_9F035040-A060-4830-BEF9-E2C5903ED201--