From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Bug: org-make-link-string incorrect with URL containing escapes [6.34a] Date: Sat, 16 Jan 2010 01:11:40 +0100 Message-ID: <02C88D47-85C1-4E21-B53E-3128FF7B0FB4@gmail.com> References: <1263562863.5459.129.camel@localhost.localdomain> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVwGa-0001OF-RC for emacs-orgmode@gnu.org; Fri, 15 Jan 2010 19:11:48 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVwGX-0001Ml-29 for emacs-orgmode@gnu.org; Fri, 15 Jan 2010 19:11:48 -0500 Received: from [199.232.76.173] (port=60193 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVwGW-0001Mh-PE for emacs-orgmode@gnu.org; Fri, 15 Jan 2010 19:11:44 -0500 Received: from mail-ew0-f209.google.com ([209.85.219.209]:41560) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NVwGW-0003kB-EV for emacs-orgmode@gnu.org; Fri, 15 Jan 2010 19:11:44 -0500 Received: by ewy1 with SMTP id 1so269964ewy.8 for ; Fri, 15 Jan 2010 16:11:42 -0800 (PST) In-Reply-To: <1263562863.5459.129.camel@localhost.localdomain> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Geert Kloosterman Cc: emacs-orgmode@gnu.org Hi Geert, wow, this was awesome! This is the best kind of bug report I can imagine. Thank you, your patch has been applied. - Carsten On Jan 15, 2010, at 2:41 PM, Geert Kloosterman wrote: > Emacs : GNU Emacs 23.1.1 (i386-redhat-linux-gnu, GTK+ Version 2.18.3) > of 2009-12-02 on x86-7.fedora.phx.redhat.com > Package: Org-mode version 6.34a > > Hi all, > > When an org link is created from an URL containing a hex escape > `org-make-link-string' creates a link that ends up corrupted the > moment > it is followed (e.g. using `org-open-at-point'). > > I've traced this back to `org-link-escape' and `org-link-unescape'. > The > following shows how the hex code "%2B" is converted to a "+" after an > escaping round trip: > > (org-link-unescape (org-link-escape "http://some.host.com/form?&id=blah%2Bblah > ")) > ==> > "http://some.host.com/form?&id=blah+blah" > > In my case this small change ended up in a broken URL. > > Additionally, when the URL-escape happens to be in lower case (or > otherwise not present in `org-link-escape-chars') we end up with an > error: > > (org-link-unescape (org-link-escape "http://some.host.com/form?&id=blah%2bblah > ")) > ==> > Debugger entered--Lisp error: (wrong-type-argument characterp nil) > char-to-string(nil) > ... > > When `org-url-encoding-use-url-hexify' is set to `t' we do get a > proper > round trip of the URL containing hex-escapes: > > (setq org-url-encoding-use-url-hexify t) > (org-link-unescape (org-link-escape "http://some.host.com/form?&id=blah%2bblah > ")) > ==> > "http://some.host.com/form?&id=blah%2bblah" > > > Setting `org-url-encoding-use-url-hexify' does not fix the complete > problem however: `org-open-at-point' still did not end up with the > proper URL. Within `org-open-at-point' there is another call to > `org-link-escape': > > (org-link-escape path org-link-escape-chars-browser) > > This time a mapping table is passed in explicitly (the second > argument). > However, when `org-url-encoding-use-url-hexify' is set,a this mapping > table isn't used, resulting (again) in a broken URL. > > I have attached a patch that fixes the problem: do not use url- > hexify in > `org-link-escape' and `org-link-unescape' when an explicit mapping > table > has been specified. > > In summary: > - the default behaviour of `org-link-escape', with > `org-url-encoding-use-url-hexify' set to nil, has some issues with > handling URLS which contain url-encoded hex escapes > - when a mapping table is passed to `org-link-escape' and > `org-link-unescape', they should probably not use url-hexify. > Patch attached. > > Best regards, > Geert Kloosterman > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode - Carsten