# HG changeset patch # User Chong Yidong # Date 1238710577 0 # Node ID 14923c394d62481a70cd9864ceeba9674a9e6e81 # Parent 607b4f5da59c8b3495aa4f7eb9141f7808a941f0 * dired.el (dired-get-filename): Always pass filename through `read' to ensure unquoting is performed (Bug#2862). diff -r 607b4f5da59c -r 14923c394d62 lisp/ChangeLog --- a/lisp/ChangeLog Thu Apr 02 21:12:54 2009 +0000 +++ b/lisp/ChangeLog Thu Apr 02 22:16:17 2009 +0000 @@ -1,3 +1,8 @@ +2009-04-02 Chong Yidong + + * dired.el (dired-get-filename): Always pass filename through + `read' to ensure unquoting is performed (Bug#2862). + 2009-04-02 Stefan Monnier * doc-view.el (doc-view-mode): Don't give up if the file doesn't exist. diff -r 607b4f5da59c -r 14923c394d62 lisp/dired.el --- a/lisp/dired.el Thu Apr 02 21:12:54 2009 +0000 +++ b/lisp/dired.el Thu Apr 02 22:16:17 2009 +0000 @@ -1950,11 +1950,14 @@ ;; Get rid of the mouse-face property that file names have. (set-text-properties 0 (length file) nil file) ;; Unquote names quoted by ls or by dired-insert-directory. - (while (string-match - "\\(?:[^\\]\\|\\`\\)\\(\\\\[0-7][0-7][0-7]\\)" file) - (setq file (replace-match - (read (concat "\"" (match-string 1 file) "\"")) - nil t file 1))) + ;; This code was written using `read' to unquote, because + ;; it's faster than substituting \007 (4 chars) -> ^G (1 + ;; char) etc. in a lisp loop. Unfortunately, this decision + ;; has necessitated hacks such as dealing with filenames + ;; with quotation marks in their names. + (while (string-match "\\(?:[^\\]\\|\\`\\)\\(\"\\)" file) + (setq file (replace-match "\\\"" nil t file 1))) + (setq file (read (concat "\"" file "\""))) ;; The above `read' will return a unibyte string if FILE ;; contains eight-bit-control/graphic characters. (if (and enable-multibyte-characters