summaryrefslogtreecommitdiff
path: root/lisp/auth-source.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2025-09-15 11:43:52 +0200
committerMichael Albinus <michael.albinus@gmx.de>2025-09-15 11:43:52 +0200
commit72c19d0f395e8883c65689c86e79905a34d36586 (patch)
treebb277e51742b2f473246287fc1048784df5ffa75 /lisp/auth-source.el
parent897d32285fc17b8afd889b1f733aed7149b50a5c (diff)
Improve check for netrc tokens
* doc/misc/auth.texi (Help for users): Mention also "#" inside tokens. * lisp/auth-source.el (auth-source-netrc-create): Better check for token format. * test/lisp/auth-source-tests.el (auth-source-backend-parse-json): New test. (auth-source-test-netrc-create-secret): Extend test.
Diffstat (limited to 'lisp/auth-source.el')
-rw-r--r--lisp/auth-source.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 442fe2fc1e3..e7c8f43b7f9 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1468,7 +1468,9 @@ See `auth-source-search' for details on SPEC."
(when (and (stringp data)
(< 0 (length data)))
(when (eq r 'secret)
- (setq save-function t))
+ (setq save-function
+ (not (and (string-match-p "\"" data)
+ (string-match-p "'" data)))))
;; this function is not strictly necessary but I think it
;; makes the code clearer -tzz
(let ((printer (lambda ()
@@ -1484,9 +1486,12 @@ See `auth-source-search' for details on SPEC."
(secret "password")
(port "port") ; redundant but clearer
(t (symbol-name r)))
- (if (string-match "[\"# ]" data)
- (format "%S" data)
- data)))))
+ (cond
+ ((string-match-p "\"" data)
+ (format "'%s'" data))
+ ((string-match-p "['# ]" data)
+ (format "%S" data))
+ (t data))))))
(setq add (concat add (funcall printer)))))))
(when save-function