(defun auth-source-pass--match-regexp (s)
(rx-to-string ; autoloaded
`(: (or bot "/")
- (or (: (? (group-n 20 (+ (not (in ?\ ?/ ,s)))) "@")
- (group-n 10 (+ (not (in ?\ ?/ ?@ ,s))))
- (? ,s (group-n 30 (+ (not (in ?\ ?/ ,s))))))
- (: (group-n 11 (+ (not (in ?\ ?/ ?@ ,s))))
- (? ,s (group-n 31 (+ (not (in ?\ ?/ ,s)))))
- (? "/" (group-n 21 (+ (not (in ?\ ?/ ,s)))))))
+ (or (: (? (group-n 20 (+ (not (in ?/ ,s)))) "@") ; user prefix
+ (group-n 10 (+ (not (in ?/ ?@ ,s)))) ; host
+ (? ,s (group-n 30 (+ (not (in ?\s ?/ ,s)))))) ; port
+ (: (group-n 11 (+ (not (in ?/ ?@ ,s)))) ; host
+ (? ,s (group-n 31 (+ (not (in ?\s ?/ ,s))))) ; port
+ (? "/" (group-n 21 (+ (not (in ?/ ,s))))))) ; user suffix
eot)
'no-group))
;; This hard codes `auth-source-pass-port-separator' to ":"
(defun erc-compat--29-auth-source-pass--retrieve-parsed (seen e port-number-p)
(when (string-match (rx (or bot "/")
- (or (: (? (group-n 20 (+ (not (in " /:")))) "@")
- (group-n 10 (+ (not (in " /:@"))))
+ (or (: (? (group-n 20 (+ (not (in "/:")))) "@")
+ (group-n 10 (+ (not (in "/:@"))))
(? ":" (group-n 30 (+ (not (in " /:"))))))
- (: (group-n 11 (+ (not (in " /:@"))))
+ (: (group-n 11 (+ (not (in "/:@"))))
(? ":" (group-n 31 (+ (not (in " /:")))))
- (? "/" (group-n 21 (+ (not (in " /:")))))))
+ (? "/" (group-n 21 (+ (not (in "/:")))))))
eot)
e)
(puthash e `( :host ,(or (match-string 10 e) (match-string 11 e))
(ert-deftest auth-source-pass-any-host ()
(auth-source-pass--with-store '(("foo" ("port" . "foo-port") ("host" . "foo-user"))
("bar"))
- (should-not (auth-source-pass-search :host t))))
+ (let ((inhibit-message t)) ; silence "... does not handle host wildcards."
+ (should-not (auth-source-pass-search :host t)))))
(ert-deftest auth-source-pass-undefined-host ()
(auth-source-pass--with-store '(("foo" ("port" . "foo-port") ("host" . "foo-user"))
;; with slightly more realistic and less legible values.
(ert-deftest auth-source-pass-extra-query-keywords--suffixed-user ()
- (let ((store (sort (copy-sequence '(("x.com:42/b@r" (secret . "a"))
- ("b@r@x.com" (secret . "b"))
+ (let ((store (sort (copy-sequence '(("x.com:42/s p@m" (secret . "a"))
+ ("s p@m@x.com" (secret . "b"))
("x.com" (secret . "?"))
- ("b@r@y.org" (secret . "c"))
- ("fake.com" (secret . "?"))
- ("fake.com/b@r" (secret . "d"))
- ("y.org/b@r" (secret . "?"))
- ("b@r@fake.com" (secret . "e"))))
+ ("s p@m@y.org" (secret . "c"))
+ ("fa ke" (secret . "?"))
+ ("fa ke/s p@m" (secret . "d"))
+ ("y.org/s p@m" (secret . "?"))
+ ("s p@m@fa ke" (secret . "e"))))
(lambda (&rest _) (zerop (random 2))))))
(auth-source-pass--with-store store
(auth-source-pass-enable)
(let* ((auth-source-pass-extra-query-keywords t)
- (results (auth-source-search :host '("x.com" "fake.com" "y.org")
- :user "b@r"
+ (results (auth-source-search :host '("x.com" "fa ke" "y.org")
+ :user "s p@m"
:require '(:user) :max 5)))
(dolist (result results)
(setf (plist-get result :secret) (auth-info-password result)))
(should (equal results
- '((:host "x.com" :user "b@r" :secret "b")
- (:host "x.com" :user "b@r" :port "42" :secret "a")
- (:host "fake.com" :user "b@r" :secret "e")
- (:host "fake.com" :user "b@r" :secret "d")
- (:host "y.org" :user "b@r" :secret "c"))))))))
+ '((:host "x.com" :user "s p@m" :secret "b")
+ (:host "x.com" :user "s p@m" :port "42" :secret "a")
+ (:host "fa ke" :user "s p@m" :secret "e")
+ (:host "fa ke" :user "s p@m" :secret "d")
+ (:host "y.org" :user "s p@m" :secret "c"))))))))
;; This is a more distilled version of `suffixed-user', above. It
;; better illustrates that search order takes precedence over "/user"