unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46609: Fix shell password prompt in minibuffer (bug 43302)
@ 2021-02-18  1:13 Ryan Prior via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-02-18 11:44 ` Lars Ingebrigtsen
  2021-02-18 14:39 ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: Ryan Prior via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-02-18  1:13 UTC (permalink / raw)
  To: 46609

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

============================================================






^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-02-18 15:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-18  1:13 bug#46609: Fix shell password prompt in minibuffer (bug 43302) Ryan Prior via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-18 11:44 ` Lars Ingebrigtsen
2021-02-18 11:50   ` Andreas Schwab
2021-02-18 11:56     ` Lars Ingebrigtsen
2021-02-18 14:42   ` Eli Zaretskii
2021-02-18 15:29     ` Lars Ingebrigtsen
2021-02-18 14:39 ` Eli Zaretskii
2021-02-18 14:47   ` Lars Ingebrigtsen
2021-02-18 15:01     ` Eli Zaretskii
2021-02-18 15:26       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).