summaryrefslogtreecommitdiff
path: root/lisp/auth-source.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2024-01-11 12:30:05 +0100
committerMichael Albinus <michael.albinus@gmx.de>2024-01-11 12:30:05 +0100
commitef08f94cbec1a9fb98bc1bbfcc88cd399b7ff8d0 (patch)
treec99a9bd2976f4f01589ed74043e6c2581e33bfab /lisp/auth-source.el
parentc7aa5c6d2b838e2fd84db4cbdafdbd546dd87832 (diff)
Support numeric port numbers in auth-source-macos-keychain
* lisp/auth-source.el (auth-source-macos-keychain-search): Support numeric port numbers (bug#68376). (auth-source-macos-keychain-search-items): Make regexp more robust. * test/lisp/auth-source-tests.el (test-macos-keychain-search): Extend test.
Diffstat (limited to 'lisp/auth-source.el')
-rw-r--r--lisp/auth-source.el14
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 369cf4dca2e..cf93cb05fba 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1946,18 +1946,20 @@ entries for git.gnus.org:
(returned-keys (delete-dups (append
'(:host :login :port :secret)
search-keys)))
- ;; Extract host and port from spec
+ ;; Extract host, port and user from spec
(hosts (plist-get spec :host))
- (hosts (if (and hosts (listp hosts)) hosts `(,hosts)))
+ (hosts (if (consp hosts) hosts `(,hosts)))
(ports (plist-get spec :port))
- (ports (if (and ports (listp ports)) ports `(,ports)))
+ (ports (if (consp ports) ports `(,ports)))
(users (plist-get spec :user))
- (users (if (and users (listp users)) users `(,users)))
+ (users (if (consp users) users `(,users)))
;; Loop through all combinations of host/port and pass each of these to
- ;; auth-source-macos-keychain-search-items
+ ;; auth-source-macos-keychain-search-items. Convert numeric port to
+ ;; string (bug#68376).
(items (catch 'match
(dolist (host hosts)
(dolist (port ports)
+ (when (numberp port) (setq port (number-to-string port)))
(dolist (user users)
(let ((items (apply
#'auth-source-macos-keychain-search-items
@@ -2019,7 +2021,7 @@ entries for git.gnus.org:
(when port
(if keychain-generic
(setq args (append args (list "-s" port)))
- (setq args (append args (if (string-match "[0-9]+" port)
+ (setq args (append args (if (string-match-p "\\`[[:digit:]]+\\'" port)
(list "-P" port)
(list "-r" (substring
(format "%-4s" port)