emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r102694: * dnd.el (dnd-get-local-file


From: Jan D.
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102694: * dnd.el (dnd-get-local-file-name): Unhex of file name shall
Date: Mon, 20 Dec 2010 21:11:01 +0100
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102694
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Mon 2010-12-20 21:11:01 +0100
message:
  * dnd.el (dnd-get-local-file-name): Unhex of file name shall
   always be performed (Bug#7680).
modified:
  lisp/ChangeLog
  lisp/dnd.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-12-20 14:44:28 +0000
+++ b/lisp/ChangeLog    2010-12-20 20:11:01 +0000
@@ -1,3 +1,8 @@
+2010-12-20  Leo  <address@hidden>
+
+       * dnd.el (dnd-get-local-file-name): Unhex of file name shall
+       always be performed (Bug#7680).
+
 2010-12-20  Chong Yidong  <address@hidden>
 
        * menu-bar.el (menu-bar-kill-ring-save): Make obsolete.

=== modified file 'lisp/dnd.el'
--- a/lisp/dnd.el       2010-10-08 10:14:47 +0000
+++ b/lisp/dnd.el       2010-12-20 20:11:01 +0000
@@ -135,6 +135,16 @@
                 (string-equal system-name-no-dot hostname)))
        (concat "file://" (substring uri (+ 7 (length hostname)))))))
 
+(defsubst dnd-unescape-uri (uri)
+  (replace-regexp-in-string
+   "%[A-Fa-f0-9][A-Fa-f0-9]"
+   (lambda (arg)
+     (let ((str (make-string 1 0)))
+       (aset str 0 (string-to-number (substring arg 1) 16))
+       str))
+   uri t t))
+
+;; http://lists.gnu.org/archive/html/emacs-devel/2006-05/msg01060.html
 (defun dnd-get-local-file-name (uri &optional must-exist)
   "Return file name converted from file:/// or file: syntax.
 URI is the uri for the file.  If MUST-EXIST is given and non-nil,
@@ -144,21 +154,11 @@
                  (substring uri (1- (match-end 0))))
                 ((string-match "^file:" uri)           ; Old KDE, Motif, Sun
                  (substring uri (match-end 0))))))
-    (when (and f must-exist)
-      (setq f (replace-regexp-in-string
-              "%[A-Fa-f0-9][A-Fa-f0-9]"
-              (lambda (arg)
-                (let ((str (make-string 1 0)))
-                  (aset str 0 (string-to-number (substring arg 1) 16))
-                  str))
-              f t t))
-      (let* ((decoded-f (decode-coding-string
-                        f
-                        (or file-name-coding-system
-                            default-file-name-coding-system))))
-       (setq f (cond ((file-readable-p decoded-f) decoded-f)
-                     ((file-readable-p f) f)
-                     (t nil)))))
+    (and f (setq f (decode-coding-string (dnd-unescape-uri f)
+                                         (or file-name-coding-system
+                                             
default-file-name-coding-system))))
+    (when (and f must-exist (not (file-readable-p f)))
+      (setq f nil))
     f))
 
 (defun dnd-open-local-file (uri action)


reply via email to

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