From 34f07b1dc8517d1c7e580bff1e5ac34b69c993d6 Mon Sep 17 00:00:00 2001 From: Dario Gjorgjevski Date: Thu, 21 Nov 2019 10:10:32 +0100 Subject: [PATCH] Hide quoted passwords with spaces in Authinfo To: bug-gnu-emacs@gnu.org * lisp/auth-source.el (auth-source-netrc-looking-at-one): New function, extracted from auth-source-netrc-parse-one. (auth-source-netrc-parse-one, authinfo--hide-passwords): Use auth-source-netrc-looking-at-one. --- lisp/auth-source.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lisp/auth-source.el b/lisp/auth-source.el index 4926f67f0a..0800202914 100644 --- a/lisp/auth-source.el +++ b/lisp/auth-source.el @@ -1000,13 +1000,17 @@ auth-source-netrc-parse-next-interesting (forward-line 1) (skip-chars-forward "\t "))) +(defun auth-source-netrc-looking-at-one () + "Modify match data with one thing from the current buffer." + (or (looking-at "'\\([^']*\\)'") + (looking-at "\"\\([^\"]*\\)\"") + (looking-at "\\([^ \t\n]+\\)"))) + (defun auth-source-netrc-parse-one () "Read one thing from the current buffer." (auth-source-netrc-parse-next-interesting) - (when (or (looking-at "'\\([^']*\\)'") - (looking-at "\"\\([^\"]*\\)\"") - (looking-at "\\([^ \t\n]+\\)")) + (when (auth-source-netrc-looking-at-one) (forward-char (length (match-string 0))) (prog1 (match-string-no-properties 1) @@ -2427,7 +2431,7 @@ authinfo--hide-passwords (while (re-search-forward (format "\\(\\s-\\|^\\)\\(%s\\)\\s-+" authinfo-hidden) nil t) - (when (looking-at "[^\n\t ]+") + (when (auth-source-netrc-looking-at-one) (let ((overlay (make-overlay (match-beginning 0) (match-end 0)))) (overlay-put overlay 'display (propertize "****" 'face 'warning)) -- 2.17.1