]> git.eshelyaron.com Git - emacs.git/commitdiff
Hide quoted passwords with spaces in Authinfo
authorDario Gjorgjevski <dario.gjorgjevski+git@gmail.com>
Thu, 21 Nov 2019 12:51:55 +0000 (13:51 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 21 Nov 2019 12:51:55 +0000 (13:51 +0100)
* 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 (bug#38311).

lisp/auth-source.el

index 4926f67f0a153c8e0d067db978c2bf0de5b5e7a5..89a468570ac583e9f9ad2805a96d07746912abdb 100644 (file)
@@ -1000,13 +1000,18 @@ Note that the MAX parameter is used so we can exit the parse early."
     (forward-line 1)
     (skip-chars-forward "\t ")))
 
+(defun auth-source-netrc-looking-at-token ()
+  "Say whether the next think in the buffer is a token (password, etc).
+Match data is altered to reflect the token."
+  (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-token)
     (forward-char (length (match-string 0)))
     (prog1
         (match-string-no-properties 1)
@@ -2427,7 +2432,7 @@ passwords are revealed when point moved into the password.
       (while (re-search-forward (format "\\(\\s-\\|^\\)\\(%s\\)\\s-+"
                                         authinfo-hidden)
                                 nil t)
-        (when (looking-at "[^\n\t ]+")
+        (when (auth-source-netrc-looking-at-token)
           (let ((overlay (make-overlay (match-beginning 0) (match-end 0))))
             (overlay-put overlay 'display (propertize "****"
                                                       'face 'warning))