aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Djärv2010-12-20 21:11:01 +0100
committerJan Djärv2010-12-20 21:11:01 +0100
commitadc0b7934703173b0f351a44181a6317dcf59acf (patch)
tree6ecf730e52610ff50f5b34a1877cb260fea78b36
parent3f95d7ffba6ad40e809253025ef7384d0fc441e3 (diff)
downloademacs-adc0b7934703173b0f351a44181a6317dcf59acf.tar.gz
emacs-adc0b7934703173b0f351a44181a6317dcf59acf.zip
* dnd.el (dnd-get-local-file-name): Unhex of file name shall
always be performed (Bug#7680).
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/dnd.el30
2 files changed, 20 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 510bfcdd2c4..8b60f871d78 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12010-12-20 Leo <sdl.web@gmail.com>
2
3 * dnd.el (dnd-get-local-file-name): Unhex of file name shall
4 always be performed (Bug#7680).
5
12010-12-20 Chong Yidong <cyd@stupidchicken.com> 62010-12-20 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * menu-bar.el (menu-bar-kill-ring-save): Make obsolete. 8 * menu-bar.el (menu-bar-kill-ring-save): Make obsolete.
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."
135 (string-equal system-name-no-dot hostname))) 135 (string-equal system-name-no-dot hostname)))
136 (concat "file://" (substring uri (+ 7 (length hostname))))))) 136 (concat "file://" (substring uri (+ 7 (length hostname)))))))
137 137
138(defsubst dnd-unescape-uri (uri)
139 (replace-regexp-in-string
140 "%[A-Fa-f0-9][A-Fa-f0-9]"
141 (lambda (arg)
142 (let ((str (make-string 1 0)))
143 (aset str 0 (string-to-number (substring arg 1) 16))
144 str))
145 uri t t))
146
147;; http://lists.gnu.org/archive/html/emacs-devel/2006-05/msg01060.html
138(defun dnd-get-local-file-name (uri &optional must-exist) 148(defun dnd-get-local-file-name (uri &optional must-exist)
139 "Return file name converted from file:/// or file: syntax. 149 "Return file name converted from file:/// or file: syntax.
140URI is the uri for the file. If MUST-EXIST is given and non-nil, 150URI 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."
144 (substring uri (1- (match-end 0)))) 154 (substring uri (1- (match-end 0))))
145 ((string-match "^file:" uri) ; Old KDE, Motif, Sun 155 ((string-match "^file:" uri) ; Old KDE, Motif, Sun
146 (substring uri (match-end 0)))))) 156 (substring uri (match-end 0))))))
147 (when (and f must-exist) 157 (and f (setq f (decode-coding-string (dnd-unescape-uri f)
148 (setq f (replace-regexp-in-string 158 (or file-name-coding-system
149 "%[A-Fa-f0-9][A-Fa-f0-9]" 159 default-file-name-coding-system))))
150 (lambda (arg) 160 (when (and f must-exist (not (file-readable-p f)))
151 (let ((str (make-string 1 0))) 161 (setq f nil))
152 (aset str 0 (string-to-number (substring arg 1) 16))
153 str))
154 f t t))
155 (let* ((decoded-f (decode-coding-string
156 f
157 (or file-name-coding-system
158 default-file-name-coding-system))))
159 (setq f (cond ((file-readable-p decoded-f) decoded-f)
160 ((file-readable-p f) f)
161 (t nil)))))
162 f)) 162 f))
163 163
164(defun dnd-open-local-file (uri action) 164(defun dnd-open-local-file (uri action)