GNU bug report logs -
#6568
23.2; easypg opens blank buffer when password is incorrect
Previous Next
Reported by: Leo <sdl.web <at> gmail.com>
Date: Mon, 5 Jul 2010 16:01:02 UTC
Severity: normal
Merged with 8792
Found in versions 23.2, 23.3
Fixed in version 24.1
Done: Daiki Ueno <ueno <at> unixuser.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Leo <sdl.web <at> gmail.com> writes:
> Assume you have an encrypted file test.gpg and try to open it in emacs.
> At the password prompt, type in an incorrect one. A blank buffer is
> still opened.
>
> The tricky thing is if you save back the contents in that buffer
> (because accidentally you think you have typed in a correct password),
> the original content will be gone.
>
> It seems better for easypg not to open a blank buffer when password is
> incorrect.
Basically agree. I have worndered for a long time how to implement
this, because error handling in find-file is too complex to control.
One idea is to re-throw the error in find-file-not-found-functions
(patch attached). I'm not sure if this approach is palatable as other
basic Emacs commands. Anyway, testing would be much appreciated.
[epa-file-no-select-empty.diff (text/x-patch, inline)]
=== modified file 'lisp/epa-file.el'
--- lisp/epa-file.el 2010-01-13 08:35:10 +0000
+++ lisp/epa-file.el 2010-07-06 08:36:24 +0000
@@ -101,6 +101,14 @@
(insert (epa-file--decode-coding-string string (or coding-system-for-read
'undecided)))))
+(defvar epa-file-error nil)
+(defun epa-file--find-file-not-found-function ()
+ (save-window-excursion
+ (let ((error (copy-sequence epa-file-error)))
+ (ignore (kill-buffer))
+ (signal 'file-error
+ (cons "Opening input file" (cdr error))))))
+
(defvar last-coding-system-used)
(defun epa-file-insert-file-contents (file &optional visit beg end replace)
(barf-if-buffer-read-only)
@@ -126,11 +134,16 @@
(progn
(if replace
(goto-char (point-min)))
+ (add-hook 'find-file-not-found-functions
+ 'epa-file--find-file-not-found-function
+ nil t)
(condition-case error
(setq string (epg-decrypt-file context local-file nil))
(error
(if (setq entry (assoc file epa-file-passphrase-alist))
(setcdr entry nil))
+ (make-local-variable 'epa-file-error)
+ (setq epa-file-error error)
(signal 'file-error
(cons "Opening input file" (cdr error)))))
(make-local-variable 'epa-file-encrypt-to)
[Message part 3 (text/plain, inline)]
Regards,
--
Daiki Ueno
This bug report was last modified 13 years and 359 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.