From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Escaping links Date: Fri, 11 Aug 2017 17:31:46 +0000 Message-ID: References: <87zib65e93.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="f403045f21d0a9802805567db00e" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgDn2-00024c-BI for emacs-orgmode@gnu.org; Fri, 11 Aug 2017 13:32:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgDmz-0006Ll-78 for emacs-orgmode@gnu.org; Fri, 11 Aug 2017 13:32:04 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:35639) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dgDmy-0006Ka-To for emacs-orgmode@gnu.org; Fri, 11 Aug 2017 13:32:01 -0400 Received: by mail-wr0-f171.google.com with SMTP id k71so15703649wrc.2 for ; Fri, 11 Aug 2017 10:31:59 -0700 (PDT) In-Reply-To: <87zib65e93.fsf@nicolasgoaziou.fr> 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: Fabrice Popineau , Nicolas Goaziou Cc: "emacs-orgmode@gnu.org" --f403045f21d0a9802805567db00e Content-Type: text/plain; charset="UTF-8" Could you put some magic at the beginning of the string that indicates it is encoded? On Fri, Aug 11, 2017 at 8:15 AM Nicolas Goaziou wrote: > Hello, > > Fabrice Popineau writes: > > > Are links to a file whose name already holds (url-)escaped chars > supported? > > > > If I have a directory named "c:/temp/foo bar/" > > and files in this directory named > > foo.txt > > foo bar.txt > > foo%2Fbar.txt > > > > I can create links in an Org buffer by using `insert' but I find the > > situation a bit confusing. > > > > #+LINK: temp file:c:/temp/%s > > > > 1. [[temp:foo bar/foo bar.txt]] > > 2. [[temp:foo%20bar/foo bar.txt]] > > 3. [[temp:foo bar/foo%20bar.txt]] > > 4. [[temp:foo%20bar/foo%20bar.txt]] > > > > > > All of these links seem to work the same way. > > > > 5. [[temp:foo bar/foo%2Fbar.txt]] > > 6. [[temp:foo bar/foo%252Fbar.txt]] > > 7. [[temp:foo%20bar/foo%252Fbar.txt]] > > > > Link 5 does not work. > > > > Link 6 and 7 do work: as long as I press enter on the link, I visit the > > file. > > > > Unfortunately, if I edit these links with 'C-c C-l', doing nothing > > (return), Org replaces the escaped chars and unescape them. > > > > I have grabbed files whose name hold such %2F %3A and so on escaped > chars. > > Do I have any option to make a link point at them or should I rename > > them? > > You might get around it by not using link abbreviation. > > Anyway, the core problem here is that: > > 1. Org uses percent escaping to get around its own limitations (e.g., no > square brackets allowed in a link); > 2. it's not possible to know if a string is percent-encoded or not; > 3. percent-encoding is not idempotent. > > Using a different escaping mechanism to solve 1 and never ever > percent-decode an URL could put an end to the link mess. > > Finding an escaping mechanism that also solves 2 is yet to be done. > > > Regards, > > -- > Nicolas Goaziou > > -- John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu --f403045f21d0a9802805567db00e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Could you put some magic at the beginning of the str= ing that indicates it is encoded?=C2=A0

On Fri, Aug 11, 2017 at 8:15 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
Hello,

Fabrice Popineau <fabrice.popineau@gmail.com> writes:

> Are links to a file whose name already holds (url-)escaped chars suppo= rted?
>
> If I have a directory named "c:/temp/foo bar/"
> and files in this directory named
> foo.txt
> foo bar.txt
> foo%2Fbar.txt
>
> I can create links in an Org buffer by using `insert' but I find t= he
> situation a bit confusing.
>
> #+LINK: temp file:c:/temp/%s
>
> 1. [[temp:foo bar/foo bar.txt]]
> 2. [[temp:foo%20bar/foo bar.txt]]
> 3. [[temp:foo bar/foo%20bar.txt]]
> 4. [[temp:foo%20bar/foo%20bar.txt]]
>
>
> All of these links seem to work the same way.
>
> 5. [[temp:foo bar/foo%2Fbar.txt]]
> 6. [[temp:foo bar/foo%252Fbar.txt]]
> 7. [[temp:foo%20bar/foo%252Fbar.txt]]
>
> Link 5 does not work.
>
> Link 6 and 7 do work: as long as I press enter on the link, I visit th= e
> file.
>
> Unfortunately, if I edit these links with 'C-c C-l', doing not= hing
> (return), Org replaces the escaped chars and unescape them.
>
> I have grabbed files whose name hold such %2F %3A and so on escaped ch= ars.
> Do I have any option to make a link point at them or should I rename > them?

You might get around it by not using link abbreviation.

Anyway, the core problem here is that:

=C2=A0 1. Org uses percent escaping to get around its own limitations (e.g.= , no
=C2=A0 =C2=A0 =C2=A0square brackets allowed in a link);
=C2=A0 2. it's not possible to know if a string is percent-encoded or n= ot;
=C2=A0 3. percent-encoding is not idempotent.

Using a different escaping mechanism to solve 1 and never ever
percent-decode an URL could put an end to the link mess.

Finding an escaping mechanism that also solves 2 is yet to be done.


Regards,

--
Nicolas Goaziou

--
John

-----------------------------------
Professor John= Kitchin=C2=A0
Doherty Hall A207F
Department of Chemical Engineering<= br>Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
=
--f403045f21d0a9802805567db00e--