From 099168a7560265ca5ef940879bc4643ba396defd Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Mon, 25 Jun 2018 19:11:41 -0400 Subject: [PATCH v1] Detect Chinese sudo password prompts (Bug#31075) * lisp/comint.el (comint-password-prompt-regexp): Allow text between the prompt prefix and password equivalent. * lisp/eshell/esh-mode.el (eshell-password-prompt-regexp): Accept some unicode alternatives to ":". * test/lisp/comint-tests.el (comint-testsuite-password-strings): Add test case. --- lisp/comint.el | 3 ++- lisp/eshell/esh-mode.el | 2 +- test/lisp/comint-tests.el | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/comint.el b/lisp/comint.el index 71a2b5eca5..03c1193f13 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -360,7 +360,8 @@ comint-password-prompt-regexp "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "PEM" "SUDO" "[sudo]" "Repeat" "Bad" "Retype") t) - " +\\)" + ;; Allow for user name to precede password equivalent (Bug#31075). + " +.*\\)" "\\(?:" (regexp-opt password-word-equivalents) "\\|Response\\)" "\\(?:\\(?:, try\\)? *again\\| (empty for no passphrase)\\| (again)\\)?" ;; "[[:alpha:]]" used to be "for", which fails to match non-English. diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index bbb74c3d86..80e22e52a2 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -182,7 +182,7 @@ eshell-preoutput-filter-functions :group 'eshell-mode) (defcustom eshell-password-prompt-regexp - (format "\\(%s\\).*:\\s *\\'" (regexp-opt password-word-equivalents)) + (format "\\(%s\\)[^::៖]*[::៖]\\s *\\'" (regexp-opt password-word-equivalents)) "Regexp matching prompts for passwords in the inferior process. This is used by `eshell-watch-for-password-prompt'." :type 'regexp diff --git a/test/lisp/comint-tests.el b/test/lisp/comint-tests.el index 64898888ba..e8c79b9ed7 100644 --- a/test/lisp/comint-tests.el +++ b/test/lisp/comint-tests.el @@ -36,6 +36,7 @@ comint-testsuite-password-strings "Enter same passphrase again: " ; ssh-keygen "Passphrase for key root@GNU.ORG: " ; plink "[sudo] password for user:" ; Ubuntu sudo + "[sudo] user 的密码:" ; localized "Password (again):" "Enter password:" "Mot de Passe:" ; localized -- 2.11.0