[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pdf-tools 98bfeb638a 3/7: Don't retry with the same cached
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pdf-tools 98bfeb638a 3/7: Don't retry with the same cached password upon decryption failure |
Date: |
Thu, 14 Mar 2024 07:01:12 -0400 (EDT) |
branch: elpa/pdf-tools
commit 98bfeb638aaef37c17266accdb3b5a153540d452
Author: Miha Rihtaršič <miha@kamnitnik.top>
Commit: Miha Rihtaršič <miha@kamnitnik.top>
Don't retry with the same cached password upon decryption failure
Password cache may contain a stale password if a pdf file's password is
modified. Re-read a new password without cache in this case, rather than
retry
with the same cached password 3 times and fail.
---
lisp/pdf-view.el | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/lisp/pdf-view.el b/lisp/pdf-view.el
index d45571adfd..9cfb188183 100644
--- a/lisp/pdf-view.el
+++ b/lisp/pdf-view.el
@@ -470,14 +470,23 @@ PNG images in Emacs buffers."
(prompt "Enter password for pdf document: ")
(i 3)
key password)
+
(when fn
(setq prompt (format "Enter password for `%s': "
(abbreviate-file-name fn)))
- (setq key (concat "/pdf-tools" fn)))
+ (setq key (concat "/pdf-tools" fn))
+ ;; First, try with a cached password
+ (when (setq password (password-read-from-cache key))
+ (ignore-errors (pdf-info-open nil password))
+ (when (pdf-info-encrypted-p)
+ (password-cache-remove key))))
+
(while (and (> i 0)
(pdf-info-encrypted-p))
(setq i (1- i))
- (setq password (password-read prompt key))
+ ;; Cached password was not present or valid, try reading a new password
+ ;; without cache.
+ (setq password (password-read prompt))
(setq prompt "Invalid password, try again: ")
(ignore-errors (pdf-info-open nil password)))
(pdf-info-open nil password)
- [nongnu] elpa/pdf-tools updated (c69e7656a4 -> fa4d26bc85), ELPA Syncer, 2024/03/14
- [nongnu] elpa/pdf-tools 98bfeb638a 3/7: Don't retry with the same cached password upon decryption failure,
ELPA Syncer <=
- [nongnu] elpa/pdf-tools 47610debf7 6/7: Merge pull request #263 from jakanakaevangeli/decrypt-no-file, ELPA Syncer, 2024/03/14
- [nongnu] elpa/pdf-tools 20c692060a 4/7: Support 'revert-buffer' on encrypted documents, ELPA Syncer, 2024/03/14
- [nongnu] elpa/pdf-tools f12900eda4 5/7: Fixes obsolete outline commands in PDF Outline (#265), ELPA Syncer, 2024/03/14
- [nongnu] elpa/pdf-tools 388950ae94 2/7: Support decryption of non-file-visiting pdf buffers, ELPA Syncer, 2024/03/14
- [nongnu] elpa/pdf-tools f01f52dfe7 1/7: autobuild: Update gentoo packages, ELPA Syncer, 2024/03/14
- [nongnu] elpa/pdf-tools fa4d26bc85 7/7: Merge pull request #255 from thanosapollo/#fix-gentoo-autobuild, ELPA Syncer, 2024/03/14