> Date: Wed, 17 Nov 2010 21:43:59 +0100
> From: dm...@ictsoc.de
> To: vincent....@hotmail.fr
> Subject: Re: [Orgmode] %20 in file://... URL
> CC: emacs-orgmode@gnu.org; carsten.domi...@gmail.com
> 

[...]

Hello,

Sorry for the delay, I was on business trip. 
>  
> Thanks for sending the patch, but it won't provide a clean solution to
> the problem: The function modified by your patch works under the
> assumption, that for example the sequence %3A represents a percent
> escaped colon.  But the function that creates the link in the first
> place does not percent-escape chars 

Er, in my situation I create the link with another package, and I *did*
escaped the colon.

> -- If we use just this patch, opening a link to a file literarally
> called "%3A.org" will fail.
>  
> So we need to modify all functions that create links to propertly
> percent-escape the part of a link that follows the link type in order
> to make all functions unescape the link.
>  
> Good news: Reworking the percent-escaping is a work in progress on my
> list[1] and if it is finished and accepted, the problem should be
> solved.
>  
> Best,
>   -- David

I see, so I understand that you will someday modify a function creating
links in order to implement character escaping. I can give a hand if
tell me the function name.

I also send you my patch with a git diff, just in case (with same
changelog attached again). Sorry for using `diff -c', I just followed
the info node `(emacs) Sending Patches'

   Vincent.

diff --git a/lisp/org.el b/lisp/org.el
index 201dd87..4e2e2c4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9639,9 +9639,28 @@ to search for.  If LINE or SEARCH is given, the file will be
 opened in Emacs, unless an entry from org-file-apps that makes
 use of groups in a regexp matches.
 If the file does not exist, an error is thrown."
-  (let* ((file (if (equal path "")
+  (let* ((%xx-decoded-path 
+	  (let ((pos 0) (%xx-decoded-path path))
+	    (setq %xx-decoded-path path)
+	    (while (setq pos (string-match "%\\([0-9A-F]\\)\\([0-9A-F]\\)" %xx-decoded-path pos))
+	      (setq pos (1+ pos)
+		    %xx-decoded-path (replace-match 
+				      (string (let ((code 0) digit)
+						(dotimes (i 2)
+						  (setq 
+						   digit (aref (match-string (1+ i) %xx-decoded-path) 0)
+						   code (+ (if (<= digit ?9)
+							       (- digit ?0)
+							     (- digit 55))
+							   (* 16 code)))) code))
+				      t t %xx-decoded-path)))
+	    ;; remove //localhost/ prefix if any
+	    (and (string-match "\\`//localhost/" %xx-decoded-path)
+		 (setq %xx-decoded-path (substring %xx-decoded-path 12)))
+	    %xx-decoded-path))
+	 (file (if (equal path "")
 		   buffer-file-name
-		 (substitute-in-file-name (expand-file-name path))))
+		 (substitute-in-file-name (expand-file-name %xx-decoded-path))))
 	 (file-apps (append org-file-apps (org-default-apps)))
 	 (apps (org-remove-if
 		'org-file-apps-entry-match-against-dlink-p file-apps))
2010-11-13  Vincent Belaïche  <vincen...@users.sourceforge.net>

        * org.el (org-open-file): Decode %XX escapes in URL with file
        type, so that applications other than browsers are not confused with 
the filename.

_______________________________________________
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

Reply via email to