emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [bug] Org link dialog escapes URL spaces incorrectly


From: Nick Dokos
Subject: Re: [O] [bug] Org link dialog escapes URL spaces incorrectly
Date: Sun, 13 Nov 2011 12:32:35 -0500

David Maus <address@hidden> wrote:

> First sorry for the late response, some pressing family matters kept
> me busy last week.
> 
> At Sun, 06 Nov 2011 17:29:06 -0500,
> Nick Dokos wrote:
> > No, I mean the handling in org-insert-link itself:
> >
> > line 9048 says
> >
> >                 (setq link (org-extract-attributes
> >                     (org-link-unescape (org-match-string-no-properties 1))))
> 
> This is step 4: Org reads a bracket link from the buffer and these
> links are expected to be escaped (step 2). The unescape restores the
> original link.
> 
> > but further down, on line 9114 the link is not unescaped:
> >
> >         (setq link
> >               (let ((org-completion-use-ido nil)
> >                     (org-completion-use-iswitchb nil))
> >                 (org-completing-read
> >                  "Link: "
> >                  (append
> >                   (mapcar (lambda (x) (list (concat x ":")))
> >                           all-prefixes)
> >                   (mapcar 'car org-stored-links))
> >                  nil nil nil
> >                  'tmphist
> >                  (car (car org-stored-links)))))
> Here we read the user's input and provide completion for stored links
> and registered link types. There's no need to unescape the link, we
> assume that whatever the user enters here is the link in its normal
> form.
> 
> In both cases the minibuffer contains a link in its normal form. In
> the first case obtaining the normal form requires unescaping because
> whatever the user enters in the minibuffer is escaped once before
> written to buffer.
> 
> To make things a little bit clearer lets look into the specs
> (RFC3986):
> 
> #+begin_quote
> 2.4.  When to Encode or Decode
> 
>    Under normal circumstances, the only time when octets within a URI
>    are percent-encoded is during the process of producing the URI from
>    its component parts.  This is when an implementation determines which
>    of the reserved characters are to be used as subcomponent delimiters
>    and which can be safely used as data.  Once produced, a URI is always
>    in its percent-encoded form.
> #+end_quote
> 
> In other words: Steps 2 and 4, escaping and unescaping when a link is
> written to or read from the buffer has nothing to do with
> percent-escaping of URIs. Org just happens to use the percent-escaping
> algorithm to store a link in the buffer and encode special chars
> (i.e. brackets).
> 

OK - thanks for the checking and the info.

> After reading the specs I'm quite confident that dropping the
> percent-escaping of HTTP links in `org-open-at-point' is the right
> thing to do: If you paste a URI from the browser or enter it manually
> Org does not *produce* the URI and therefor is not responsible for
> proper escaping or unescaping.
> 
> I think we should remove the percent-escaping in `org-open-at-point'
> after 7.8 was released and see if this works out without breaking to
> many links.
> 

Good enough for me. I don't remember whether you supplied a patch for this
(sorry, no time to check atm) but if you did, maybe the OP can test it and
make sure that it does what he expected (or maybe he's done that already -
I can't remember and I'm completely discombobulated right now, even more than
usual).

Thanks,
Nick



reply via email to

[Prev in Thread] Current Thread [Next in Thread]