[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a537814709: Don't save bookmark context from encrypted files
From: |
Lars Ingebrigtsen |
Subject: |
master a537814709: Don't save bookmark context from encrypted files |
Date: |
Mon, 19 Sep 2022 03:43:11 -0400 (EDT) |
branch: master
commit a53781470935fc0b7c7e576c3d02ed723c9587c4
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Don't save bookmark context from encrypted files
* doc/emacs/regs.texi (Bookmarks): Mention this.
* lisp/bookmark.el (bookmark-make-record): Don't include context
in encrypted files (bug#57856).
* lisp/epa-hook.el (epa-file-name-p): New function.
---
doc/emacs/regs.texi | 3 ++-
etc/NEWS | 5 +++++
lisp/bookmark.el | 13 ++++++++++++-
lisp/epa-hook.el | 4 ++++
4 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/doc/emacs/regs.texi b/doc/emacs/regs.texi
index fb93601879..ef9187bb9a 100644
--- a/doc/emacs/regs.texi
+++ b/doc/emacs/regs.texi
@@ -381,7 +381,8 @@ jump to the bookmark.
@code{bookmark-jump} can find the proper position even if the file is
modified slightly. The variable @code{bookmark-search-size} says how
many characters of context to record on each side of the bookmark's
-position.
+position. (In buffers that are visiting encrypted files, no context
+is saved in the bookmarks file no matter the value of this variable.)
Here are some additional commands for working with bookmarks:
diff --git a/etc/NEWS b/etc/NEWS
index e5d9b1ca23..a739d74b65 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -180,6 +180,11 @@ of 'user-emacs-directory'.
* Incompatible changes in Emacs 29.1
++++
+*** bookmarks no longer include context for encrypted files.
+If you're visiting an encrypted file, setting a bookmark no longer
+includes excerpts from that buffer in the bookmarks file.
+
---
*** 'show-paren-mode' is now disabled in 'special-mode' buffers.
In Emacs versions previous to Emacs 28.1, 'show-paren-mode' defaulted
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 8dfc16bf9f..f150a24bbf 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -594,7 +594,18 @@ equivalently just return ALIST without NAME.")
(defun bookmark-make-record ()
"Return a new bookmark record (NAME . ALIST) for the current location."
- (let ((record (funcall bookmark-make-record-function)))
+ (let* ((bookmark-search-size
+ ;; If we're in a buffer that's visiting an encrypted file,
+ ;; don't include any context in the bookmark file, because
+ ;; that would leak (possibly secret) data.
+ (if (and buffer-file-name
+ (or (and (fboundp 'epa-file-name-p)
+ (epa-file-name-p buffer-file-name))
+ (and (fboundp 'tramp-crypt-file-name-p)
+ (tramp-crypt-file-name-p buffer-file-name))))
+ 0
+ bookmark-search-size))
+ (record (funcall bookmark-make-record-function)))
;; Set up default name if the function does not provide one.
(unless (stringp (car record))
(if (car record) (push nil record))
diff --git a/lisp/epa-hook.el b/lisp/epa-hook.el
index 18e47c682e..70c3030881 100644
--- a/lisp/epa-hook.el
+++ b/lisp/epa-hook.el
@@ -88,6 +88,10 @@ interface, update `file-name-handler-alist'."
epa-file-inhibit-auto-save)
(auto-save-mode 0)))
+(defun epa-file-name-p (file)
+ "Say whether FILE is handled by `epa-file'."
+ (and auto-encryption-mode (string-match-p epa-file-name-regexp file)))
+
(define-minor-mode auto-encryption-mode
"Toggle automatic file encryption/decryption (Auto Encryption mode)."
:global t :init-value t :group 'epa-file :version "23.1"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master a537814709: Don't save bookmark context from encrypted files,
Lars Ingebrigtsen <=