Add choice to reshow certificate information (Bug#31877)

In various situations, the window displaying the certificate
information can be hidden (such as if the user accidentally presses ?,
which causes the read-multiple-choice help window to replace it).
Instead of leaving the user to make a choice blindly, add a choice to
reshow the certification information.

* lisp/net/nsm.el (nsm-query-user): Add reshow choice.
This commit is contained in:
Allen Li 2018-08-01 03:04:26 -07:00 committed by Noam Postavsky
parent 6f2c471689
commit 3bbf21b913

View file

@ -319,29 +319,34 @@ unencrypted."
t)))) t))))
(defun nsm-query-user (message args cert) (defun nsm-query-user (message args cert)
(let ((buffer (get-buffer-create "*Network Security Manager*"))) (catch 'return
(save-window-excursion (while t
;; First format the certificate and warnings. (let ((buffer (get-buffer-create "*Network Security Manager*")))
(with-help-window buffer (save-window-excursion
(with-current-buffer buffer ;; First format the certificate and warnings.
(erase-buffer) (with-help-window buffer
(when (> (length cert) 0) (with-current-buffer buffer
(insert cert "\n")) (erase-buffer)
(let ((start (point))) (when (> (length cert) 0)
(insert (apply #'format-message message args)) (insert cert "\n"))
(goto-char start) (let ((start (point)))
;; Fill the first line of the message, which usually (insert (apply #'format-message message args))
;; contains lots of explanatory text. (goto-char start)
(fill-region (point) (line-end-position))))) ;; Fill the first line of the message, which usually
;; Then ask the user what to do about it. ;; contains lots of explanatory text.
(unwind-protect (fill-region (point) (line-end-position)))))
(cadr ;; Then ask the user what to do about it.
(read-multiple-choice (pcase (unwind-protect
"Continue connecting?" (cadr
'((?a "always" "Accept this certificate this session and for all future sessions.") (read-multiple-choice
(?s "session only" "Accept this certificate this session only.") "Continue connecting?"
(?n "no" "Refuse to use this certificate, and close the connection.")))) '((?a "always" "Accept this certificate this session and for all future sessions.")
(kill-buffer buffer))))) (?s "session only" "Accept this certificate this session only.")
(?n "no" "Refuse to use this certificate, and close the connection.")
(?r "reshow" "Reshow certificate information."))))
(kill-buffer buffer))
("reshow")
(val (throw 'return val))))))))
(defun nsm-save-host (host port status what permanency) (defun nsm-save-host (host port status what permanency)
(let* ((id (nsm-id host port)) (let* ((id (nsm-id host port))