summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2024-03-26 10:11:26 +0800
committerPo Lu <luangruo@yahoo.com>2024-03-26 10:11:26 +0800
commit728bf2c9e5353e68b16808ae455223549c16efc6 (patch)
treece2a4aaf1081bab52fb7b4f2e6b7a312ce9da5ba /lisp
parent7fba25cf5344f5c3507aedf59e6ae099e7662508 (diff)
downloademacs-728bf2c9e5353e68b16808ae455223549c16efc6.tar.gz
Prevent passwords from being recorded during text conversion
* doc/lispref/commands.texi (Misc Events): Document new value of text-conversion-style. * java/org/gnu/emacs/EmacsService.java (EmacsService) <IC_MODE_PASSWORD>: New constant. * java/org/gnu/emacs/EmacsView.java (onCreateInputConnection): Set TYPE_TEXT_VARIATION_PASSWORD and IME_FLAG_FORCE_ASII if mode is IC_MODE_PASSWORD. * lisp/subr.el (read-passwd): Set text-conversion-style to `password'. * src/androidgui.h (enum android_ic_mode): New value ANDROID_IC_MODE_PASSWORD. * src/androidterm.c (android_reset_conversion): Handle `password'. * src/buffer.c (syms_of_buffer) <&BVAR (current_buffer, text_conversion_style)>: Update doc string. * src/textconv.c (syms_of_textconv) <Qpassword>: New DEFSYM. <Vtext_conversion_edits>: Fix typos in doc string.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/subr.el16
1 files changed, 10 insertions, 6 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 3de4412637f..90dbfc75d52 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3405,6 +3405,10 @@ with Emacs. Do not call it directly in your own packages."
(+ i beg) (+ 1 i beg)
'help-echo "C-u: Clear password\nTAB: Toggle password visibility"))))
+;; Actually in textconv.c.
+(defvar overriding-text-conversion-style)
+(declare-function set-text-conversion-style "textconv.c")
+
(defun read-passwd (prompt &optional confirm default)
"Read a password, prompting with PROMPT, and return it.
If optional CONFIRM is non-nil, read the password twice to make sure.
@@ -3445,7 +3449,8 @@ by doing (clear-string STRING)."
(add-hook 'post-command-hook #'read-passwd--hide-password nil t))
(unwind-protect
(let ((enable-recursive-minibuffers t)
- (read-hide-char (or read-hide-char ?*)))
+ (read-hide-char (or read-hide-char ?*))
+ (overriding-text-conversion-style 'password))
(read-string prompt nil t default)) ; t = "no history"
(when (buffer-live-p minibuf)
(with-current-buffer minibuf
@@ -3457,7 +3462,10 @@ by doing (clear-string STRING)."
#'read-passwd--hide-password 'local)
(kill-local-variable 'post-self-insert-hook)
;; And of course, don't keep the sensitive data around.
- (erase-buffer))))))))
+ (erase-buffer)
+ ;; Then restore the previous text conversion style.
+ (when (fboundp 'set-text-conversion-style)
+ (set-text-conversion-style text-conversion-style)))))))))
(defvar read-number-history nil
"The default history for the `read-number' function.")
@@ -3867,10 +3875,6 @@ confusing to some users.")
from--tty-menu-p) ; invoked via TTY menu
use-dialog-box)))
-;; Actually in textconv.c.
-(defvar overriding-text-conversion-style)
-(declare-function set-text-conversion-style "textconv.c")
-
(defun y-or-n-p (prompt)
"Ask user a \"y or n\" question.
Return t if answer is \"y\" and nil if it is \"n\".