summaryrefslogtreecommitdiff
path: root/lisp/dnd.el
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2010-12-20 21:11:01 +0100
committerJan Djärv <jan.h.d@swipnet.se>2010-12-20 21:11:01 +0100
commitadc0b7934703173b0f351a44181a6317dcf59acf (patch)
tree6ecf730e52610ff50f5b34a1877cb260fea78b36 /lisp/dnd.el
parent3f95d7ffba6ad40e809253025ef7384d0fc441e3 (diff)
downloademacs-adc0b7934703173b0f351a44181a6317dcf59acf.tar.gz
* dnd.el (dnd-get-local-file-name): Unhex of file name shall
always be performed (Bug#7680).
Diffstat (limited to 'lisp/dnd.el')
-rw-r--r--lisp/dnd.el30
1 files changed, 15 insertions, 15 deletions
diff --git a/lisp/dnd.el b/lisp/dnd.el
index cbbef384436..0d2316e12b1 100644
--- a/lisp/dnd.el
+++ b/lisp/dnd.el
@@ -135,6 +135,16 @@ Return nil if URI is not a local file."
(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 @@ Return nil if URI is not a local file."
(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)