[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46609: Fix shell password prompt in minibuffer (bug 43302)
From: |
Ryan Prior |
Subject: |
bug#46609: Fix shell password prompt in minibuffer (bug 43302) |
Date: |
Thu, 18 Feb 2021 01:13:58 +0000 |
The current comint-password-prompt-regexp does not tolerate newlines at
the end of the prompt, so a string like "Password:\n" will not be
recognized as a password prompt in shell-mode. Before Emacs 27
(74277b0e881) newlines were tolerated here, so this is a regression, and
as a result I would sometimes echo my password in plain text where
previously it would be hidden.
The first patch in this series updates the regexp to use the :space:
Unicode character class for trailing space characters instead of
:blank:, which includes /only/ horizontal whitespace.
The second patch updates comint-watch-for-password-prompt to trim
trailing newlines from the ~string~ argument, which avoids showing the
user a fat password prompt with newlines in the middle.
I am not a Unicode expert and don't know if there might be undesirable
side-effects from using :space: instead of :blank:. However, in my
manual testing these change give me the exact behavior I'm after.
I pair-programmed with Nick Drozd to diagnose and fix this issue. Thanks
Nick!
===File
/home/ryan/dev/emacs/patches/0001-lisp-comint.el-comint-password-prompt-regexp-Allow-e.patch===
>From 6c9aa1f08b215abfb69f4f53f622289494588eea Mon Sep 17 00:00:00 2001
From: Ryan Prior <ryanprior@hey.com>
Subject: [PATCH 1/2] lisp/comint.el (comint-password-prompt-regexp): Allow
ending newline.
---
lisp/comint.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/comint.el b/lisp/comint.el
index 57df6bfb19..0bc358bf51 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -378,7 +378,7 @@ This variable is buffer-local."
"\\(?:" (regexp-opt password-word-equivalents) "\\|Response\\)"
"\\(?:\\(?:, try\\)? *again\\| (empty for no passphrase)\\| (again)\\)?"
;; "[[:alpha:]]" used to be "for", which fails to match non-English.
- "\\(?: [[:alpha:]]+ .+\\)?[[:blank:]]*[::៖][[:blank:]]*\\'")
+ "\\(?: [[:alpha:]]+ .+\\)?[[:blank:]]*[::៖][[:space:]]*\\'")
"Regexp matching prompts for passwords in the inferior process.
This is used by `comint-watch-for-password-prompt'."
:version "27.1"
--
2.30.1
============================================================
===File
/home/ryan/dev/emacs/patches/0002-lisp-comint.el-comint-watch-for-password-prompt-Trim.patch===
>From a9260384dfc0ced53d88380724c899f295ce0944 Mon Sep 17 00:00:00 2001
From: Ryan Prior <ryanprior@hey.com>
Subject: [PATCH 2/2] lisp/comint.el (comint-watch-for-password-prompt): Trim
trailing newline(s)
---
lisp/comint.el | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lisp/comint.el b/lisp/comint.el
index 0bc358bf51..c2942a13da 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2432,6 +2432,8 @@ This function could be in the list
`comint-output-filter-functions'."
(replace-regexp-in-string "\r" "" string)))
(when (string-match "^[ \n\r\t\v\f\b\a]+" string)
(setq string (replace-match "" t t string)))
+ (when (string-match "[\n]+$" string)
+ (setq string (replace-match "" t t string)))
(let ((comint--prompt-recursion-depth (1+ comint--prompt-recursion-depth)))
(if (> comint--prompt-recursion-depth 10)
(message "Password prompt recursion too deep")
--
2.30.1
============================================================
- bug#46609: Fix shell password prompt in minibuffer (bug 43302),
Ryan Prior <=