diff options
| author | F. Jason Park | 2022-11-24 21:03:03 -0800 |
|---|---|---|
| committer | F. Jason Park | 2022-12-09 06:35:36 -0800 |
| commit | dcf69a1da4a41c27cc3c8782c40df24678847f3e (patch) | |
| tree | 05ecdf59775fd996aa81882467ba827359e8082b | |
| parent | acd462b0306ead1b47278e810e11a3d66e4dd2cc (diff) | |
| download | emacs-dcf69a1da4a41c27cc3c8782c40df24678847f3e.tar.gz emacs-dcf69a1da4a41c27cc3c8782c40df24678847f3e.zip | |
Respect some spaces in auth-source-pass--match-regexp
* lisp/auth-source-pass.el (auth-source-pass--match-regexp): Allow an
entry's host and user fields to contain spaces, just like other
backends do.
* lisp/erc/erc-compat.el
(erc-compat--29-auth-source-pass--retrieve-parsed): Change regexp to
allow spaces in host and user components of file names.
* test/lisp/auth-source-pass-tests.el (auth-source-pass-any-host):
Silence warning message re wildcards emitted by
`auth-source-pass-search'.
(auth-source-pass-extra-query-keywords--suffixed-user): Add spaces
to users and hosts of some example entries. (Bug#58985.)
| -rw-r--r-- | lisp/auth-source-pass.el | 12 | ||||
| -rw-r--r-- | lisp/erc/erc-compat.el | 8 | ||||
| -rw-r--r-- | test/lisp/auth-source-pass-tests.el | 31 |
3 files changed, 26 insertions, 25 deletions
diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el index 74d38084480..fbb6944e26f 100644 --- a/lisp/auth-source-pass.el +++ b/lisp/auth-source-pass.el | |||
| @@ -111,12 +111,12 @@ HOSTS can be a string or a list of strings." | |||
| 111 | (defun auth-source-pass--match-regexp (s) | 111 | (defun auth-source-pass--match-regexp (s) |
| 112 | (rx-to-string ; autoloaded | 112 | (rx-to-string ; autoloaded |
| 113 | `(: (or bot "/") | 113 | `(: (or bot "/") |
| 114 | (or (: (? (group-n 20 (+ (not (in ?\ ?/ ,s)))) "@") | 114 | (or (: (? (group-n 20 (+ (not (in ?/ ,s)))) "@") ; user prefix |
| 115 | (group-n 10 (+ (not (in ?\ ?/ ?@ ,s)))) | 115 | (group-n 10 (+ (not (in ?/ ?@ ,s)))) ; host |
| 116 | (? ,s (group-n 30 (+ (not (in ?\ ?/ ,s)))))) | 116 | (? ,s (group-n 30 (+ (not (in ?\s ?/ ,s)))))) ; port |
| 117 | (: (group-n 11 (+ (not (in ?\ ?/ ?@ ,s)))) | 117 | (: (group-n 11 (+ (not (in ?/ ?@ ,s)))) ; host |
| 118 | (? ,s (group-n 31 (+ (not (in ?\ ?/ ,s))))) | 118 | (? ,s (group-n 31 (+ (not (in ?\s ?/ ,s))))) ; port |
| 119 | (? "/" (group-n 21 (+ (not (in ?\ ?/ ,s))))))) | 119 | (? "/" (group-n 21 (+ (not (in ?/ ,s))))))) ; user suffix |
| 120 | eot) | 120 | eot) |
| 121 | 'no-group)) | 121 | 'no-group)) |
| 122 | 122 | ||
diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index abbaafcd936..bd932547586 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el | |||
| @@ -176,12 +176,12 @@ If START or END is negative, it counts from the end." | |||
| 176 | ;; This hard codes `auth-source-pass-port-separator' to ":" | 176 | ;; This hard codes `auth-source-pass-port-separator' to ":" |
| 177 | (defun erc-compat--29-auth-source-pass--retrieve-parsed (seen e port-number-p) | 177 | (defun erc-compat--29-auth-source-pass--retrieve-parsed (seen e port-number-p) |
| 178 | (when (string-match (rx (or bot "/") | 178 | (when (string-match (rx (or bot "/") |
| 179 | (or (: (? (group-n 20 (+ (not (in " /:")))) "@") | 179 | (or (: (? (group-n 20 (+ (not (in "/:")))) "@") |
| 180 | (group-n 10 (+ (not (in " /:@")))) | 180 | (group-n 10 (+ (not (in "/:@")))) |
| 181 | (? ":" (group-n 30 (+ (not (in " /:")))))) | 181 | (? ":" (group-n 30 (+ (not (in " /:")))))) |
| 182 | (: (group-n 11 (+ (not (in " /:@")))) | 182 | (: (group-n 11 (+ (not (in "/:@")))) |
| 183 | (? ":" (group-n 31 (+ (not (in " /:"))))) | 183 | (? ":" (group-n 31 (+ (not (in " /:"))))) |
| 184 | (? "/" (group-n 21 (+ (not (in " /:"))))))) | 184 | (? "/" (group-n 21 (+ (not (in "/:"))))))) |
| 185 | eot) | 185 | eot) |
| 186 | e) | 186 | e) |
| 187 | (puthash e `( :host ,(or (match-string 10 e) (match-string 11 e)) | 187 | (puthash e `( :host ,(or (match-string 10 e) (match-string 11 e)) |
diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el index 1107e09b51b..d6d42ce942e 100644 --- a/test/lisp/auth-source-pass-tests.el +++ b/test/lisp/auth-source-pass-tests.el | |||
| @@ -175,7 +175,8 @@ HOSTNAME, USER and PORT are passed unchanged to | |||
| 175 | (ert-deftest auth-source-pass-any-host () | 175 | (ert-deftest auth-source-pass-any-host () |
| 176 | (auth-source-pass--with-store '(("foo" ("port" . "foo-port") ("host" . "foo-user")) | 176 | (auth-source-pass--with-store '(("foo" ("port" . "foo-port") ("host" . "foo-user")) |
| 177 | ("bar")) | 177 | ("bar")) |
| 178 | (should-not (auth-source-pass-search :host t)))) | 178 | (let ((inhibit-message t)) ; silence "... does not handle host wildcards." |
| 179 | (should-not (auth-source-pass-search :host t))))) | ||
| 179 | 180 | ||
| 180 | (ert-deftest auth-source-pass-undefined-host () | 181 | (ert-deftest auth-source-pass-undefined-host () |
| 181 | (auth-source-pass--with-store '(("foo" ("port" . "foo-port") ("host" . "foo-user")) | 182 | (auth-source-pass--with-store '(("foo" ("port" . "foo-port") ("host" . "foo-user")) |
| @@ -697,29 +698,29 @@ machine Libera.Chat password b | |||
| 697 | ;; with slightly more realistic and less legible values. | 698 | ;; with slightly more realistic and less legible values. |
| 698 | 699 | ||
| 699 | (ert-deftest auth-source-pass-extra-query-keywords--suffixed-user () | 700 | (ert-deftest auth-source-pass-extra-query-keywords--suffixed-user () |
| 700 | (let ((store (sort (copy-sequence '(("x.com:42/b@r" (secret . "a")) | 701 | (let ((store (sort (copy-sequence '(("x.com:42/s p@m" (secret . "a")) |
| 701 | ("b@r@x.com" (secret . "b")) | 702 | ("s p@m@x.com" (secret . "b")) |
| 702 | ("x.com" (secret . "?")) | 703 | ("x.com" (secret . "?")) |
| 703 | ("b@r@y.org" (secret . "c")) | 704 | ("s p@m@y.org" (secret . "c")) |
| 704 | ("fake.com" (secret . "?")) | 705 | ("fa ke" (secret . "?")) |
| 705 | ("fake.com/b@r" (secret . "d")) | 706 | ("fa ke/s p@m" (secret . "d")) |
| 706 | ("y.org/b@r" (secret . "?")) | 707 | ("y.org/s p@m" (secret . "?")) |
| 707 | ("b@r@fake.com" (secret . "e")))) | 708 | ("s p@m@fa ke" (secret . "e")))) |
| 708 | (lambda (&rest _) (zerop (random 2)))))) | 709 | (lambda (&rest _) (zerop (random 2)))))) |
| 709 | (auth-source-pass--with-store store | 710 | (auth-source-pass--with-store store |
| 710 | (auth-source-pass-enable) | 711 | (auth-source-pass-enable) |
| 711 | (let* ((auth-source-pass-extra-query-keywords t) | 712 | (let* ((auth-source-pass-extra-query-keywords t) |
| 712 | (results (auth-source-search :host '("x.com" "fake.com" "y.org") | 713 | (results (auth-source-search :host '("x.com" "fa ke" "y.org") |
| 713 | :user "b@r" | 714 | :user "s p@m" |
| 714 | :require '(:user) :max 5))) | 715 | :require '(:user) :max 5))) |
| 715 | (dolist (result results) | 716 | (dolist (result results) |
| 716 | (setf (plist-get result :secret) (auth-info-password result))) | 717 | (setf (plist-get result :secret) (auth-info-password result))) |
| 717 | (should (equal results | 718 | (should (equal results |
| 718 | '((:host "x.com" :user "b@r" :secret "b") | 719 | '((:host "x.com" :user "s p@m" :secret "b") |
| 719 | (:host "x.com" :user "b@r" :port "42" :secret "a") | 720 | (:host "x.com" :user "s p@m" :port "42" :secret "a") |
| 720 | (:host "fake.com" :user "b@r" :secret "e") | 721 | (:host "fa ke" :user "s p@m" :secret "e") |
| 721 | (:host "fake.com" :user "b@r" :secret "d") | 722 | (:host "fa ke" :user "s p@m" :secret "d") |
| 722 | (:host "y.org" :user "b@r" :secret "c")))))))) | 723 | (:host "y.org" :user "s p@m" :secret "c")))))))) |
| 723 | 724 | ||
| 724 | ;; This is a more distilled version of `suffixed-user', above. It | 725 | ;; This is a more distilled version of `suffixed-user', above. It |
| 725 | ;; better illustrates that search order takes precedence over "/user" | 726 | ;; better illustrates that search order takes precedence over "/user" |