From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: [bug] Org link dialog escapes URL spaces incorrectly Date: Sun, 13 Nov 2011 12:32:35 -0500 Message-ID: <19585.1321205555@alphaville.dokosmarshall.org> References: <23807.1320424380@alphaville.dokosmarshall.org> <24425.1320425559@alphaville.dokosmarshall.org> <26969.1320431142@alphaville.dokosmarshall.org> <87mxcazmvj.wl%dmaus@ictsoc.de> <23704.1320507536@alphaville.dokosmarshall.org> <87hb2hcnn7.wl%dmaus@ictsoc.de> <835.1320618546@alphaville.dokosmarshall.org> <87ehxcper9.wl%dmaus@ictsoc.de> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:57346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPdv8-00040a-GB for emacs-orgmode@gnu.org; Sun, 13 Nov 2011 12:32:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RPdv6-0005oC-UE for emacs-orgmode@gnu.org; Sun, 13 Nov 2011 12:32:42 -0500 Received: from g1t0028.austin.hp.com ([15.216.28.35]:26625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPdv6-0005nf-My for emacs-orgmode@gnu.org; Sun, 13 Nov 2011 12:32:40 -0500 In-Reply-To: Message from David Maus of "Sun, 13 Nov 2011 10:12:42 +0100." <87ehxcper9.wl%dmaus@ictsoc.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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: David Maus Cc: Jeff Horn , Org-mode ml , nicholas.dokos@hp.com David Maus 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