From: Björn Bidar Date: Thu, 8 Aug 2024 14:31:20 +0000 (+0300) Subject: Fix secret search with basic auth with a port in URL X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b6b044f1f862d4bf503852e3ab167dc5c036ba24;p=emacs.git Fix secret search with basic auth with a port in URL * lisp/url/url-auth.el (url-basic-auth): Fix retrieving of secrets when the URL contains a port. Amending the port to server breaks 'auth-source-search' matching for :host which is redundant as it already specified in :port. (Bug#72526) (cherry picked from commit a7a22e7c22cef0948f84daa86c9929d7b0dd6d56) --- diff --git a/lisp/url/url-auth.el b/lisp/url/url-auth.el index 8c8a33f09ac..7b5d5607172 100644 --- a/lisp/url/url-auth.el +++ b/lisp/url/url-auth.el @@ -71,8 +71,7 @@ instead of the filename inheritance method." (user (url-user href)) (pass (url-password href)) byserv retval data) - (setq server (format "%s:%d" server port) - file (cond + (setq file (cond (realm realm) ((string= "" file) "/") ((string-match "/$" file) file) @@ -93,6 +92,7 @@ instead of the filename inheritance method." (url-do-auth-source-search server type :secret) (and (url-interactive-p) (read-passwd "Password: " nil (or pass ""))))) + (setq server (format "%s:%d" server port)) (set url-basic-auth-storage (cons (list server (cons file @@ -128,6 +128,7 @@ instead of the filename inheritance method." (url-do-auth-source-search server type :secret) (and (url-interactive-p) (read-passwd "Password: "))) + server (format "%s:%d" server port) retval (base64-encode-string (format "%s:%s" user pass) t) byserv (assoc server (symbol-value url-basic-auth-storage))) (setcdr byserv