[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 86a795f 2/2: Fix problem when moving files called ~ to the trash
From: |
Lars Ingebrigtsen |
Subject: |
master 86a795f 2/2: Fix problem when moving files called ~ to the trash |
Date: |
Sat, 24 Jul 2021 07:37:18 -0400 (EDT) |
branch: master
commit 86a795f6dd6c690d83eddd753a4972c555a1ac5f
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix problem when moving files called ~ to the trash
* lisp/files.el (move-file-to-trash): Construct the trash file
name safely (bug#49711). This makes (move-file-to-trash "/tmp/~")
etc work.
---
lisp/files.el | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lisp/files.el b/lisp/files.el
index aab839e..78b7659 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -8127,16 +8127,16 @@ Otherwise, trash FILENAME using the freedesktop.org
conventions,
;; exists, but the file name may exist in the trash
;; directory even if there is no info file for it.
(when (file-exists-p
- (expand-file-name files-base trash-files-dir))
+ (directory-append trash-files-dir files-base))
(setq overwrite t
files-base (file-name-nondirectory
(make-temp-file
- (expand-file-name
- files-base trash-files-dir)
+ (directory-append
+ trash-files-dir files-base)
is-directory))))
- (setq info-fn (expand-file-name
- (concat files-base ".trashinfo")
- trash-info-dir))
+ (setq info-fn (directory-append
+ trash-info-dir
+ (concat files-base ".trashinfo")))
;; Re-check the existence (sort of).
(condition-case nil
(write-region nil nil info-fn nil 'quiet info-fn 'excl)
@@ -8145,14 +8145,14 @@ Otherwise, trash FILENAME using the freedesktop.org
conventions,
;; like Emacs-style backup file names. E.g.:
;; https://bugs.kde.org/170956
(setq info-fn (make-temp-file
- (expand-file-name files-base trash-info-dir)
+ (directory-append trash-info-dir files-base)
nil ".trashinfo"))
(setq files-base (substring (file-name-nondirectory info-fn)
0 (- (length ".trashinfo"))))
(write-region nil nil info-fn nil 'quiet info-fn)))
;; Finally, try to move the file to the trashcan.
(let ((delete-by-moving-to-trash nil)
- (new-fn (expand-file-name files-base trash-files-dir)))
+ (new-fn (directory-append trash-files-dir files-base)))
(rename-file fn new-fn overwrite)))))))))
(defsubst file-attribute-type (attributes)