[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/backports-25.2 69e0e89 23/46: Handle auth-source i
From: |
Noam Postavsky |
Subject: |
[Emacs-diffs] scratch/backports-25.2 69e0e89 23/46: Handle auth-source items with special characters on OS X |
Date: |
Sun, 2 Oct 2016 14:04:49 +0000 (UTC) |
branch: scratch/backports-25.2
commit 69e0e89f4cc0bd0b3a31fbcf65ebd3236ca8a976
Author: Jun Hao <address@hidden>
Commit: Noam Postavsky <address@hidden>
Handle auth-source items with special characters on OS X
* lisp/auth-source.el
(auth-source-macos-keychain-search-items): Handle keychain
output correctly when has special chararcters (bug#22824).
(cherry picked from commit 97ecff0783128edeb6fe5f6e441993c9bbf2a25a)
---
lisp/gnus/auth-source.el | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index 52765ce..ce881a1 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -1751,11 +1751,27 @@ entries for git.gnus.org:
items)))
items))
+
+(defun auth-source--decode-octal-string (string)
+ "Convert octal string to utf-8 string. E.g: 'a\134b' to 'a\b'"
+ (let ((list (string-to-list string))
+ (size (length string)))
+ (decode-coding-string
+ (apply #'unibyte-string
+ (loop for i = 0 then (+ i (if (eq (nth i list) ?\\) 4 1))
+ for var = (nth i list)
+ while (< i size)
+ if (eq var ?\\)
+ collect (string-to-number
+ (concat (cl-subseq list (+ i 1) (+ i 4))) 8)
+ else
+ collect var))
+ 'utf-8)))
+
(defun* auth-source-macos-keychain-search-items (coll _type _max
&key label type
host user port
&allow-other-keys)
-
(let* ((keychain-generic (eq type 'macos-keychain-generic))
(args `(,(if keychain-generic
"find-generic-password"
@@ -1784,29 +1800,32 @@ entries for git.gnus.org:
(goto-char (point-min))
(while (not (eobp))
(cond
- ((looking-at "^password: \"\\(.+\\)\"$")
+ ((looking-at "^password: \\(?:0x[0-9A-F]+\\)? *\"\\(.+\\)\"")
(setq ret (auth-source-macos-keychain-result-append
ret
keychain-generic
"secret"
- (lexical-let ((v (match-string 1)))
+ (lexical-let ((v (auth-source--decode-octal-string
+ (match-string 1))))
(lambda () v)))))
;; TODO: check if this is really the label
;; match 0x00000007 <blob>="AppleID"
- ((looking-at "^[ ]+0x00000007 <blob>=\"\\(.+\\)\"")
+ ((looking-at
+ "^[ ]+0x00000007 <blob>=\\(?:0x[0-9A-F]+\\)? *\"\\(.+\\)\"")
(setq ret (auth-source-macos-keychain-result-append
ret
keychain-generic
"label"
- (match-string 1))))
+ (auth-source--decode-octal-string (match-string 1)))))
;; match "crtr"<uint32>="aapl"
;; match "svce"<blob>="AppleID"
- ((looking-at "^[ ]+\"\\([a-z]+\\)\"[^=]+=\"\\(.+\\)\"")
+ ((looking-at
+ "^[ ]+\"\\([a-z]+\\)\"[^=]+=\\(?:0x[0-9A-F]+\\)? *\"\\(.+\\)\"")
(setq ret (auth-source-macos-keychain-result-append
ret
keychain-generic
- (match-string 1)
- (match-string 2)))))
+ (auth-source--decode-octal-string (match-string 1))
+ (auth-source--decode-octal-string (match-string 2))))))
(forward-line)))
;; return `ret' iff it has the :secret key
(and (plist-get ret :secret) (list ret))))
- [Emacs-diffs] scratch/backports-25.2 2284444 08/46: Require that the buffer that we're trying to patch exist, (continued)
- [Emacs-diffs] scratch/backports-25.2 2284444 08/46: Require that the buffer that we're trying to patch exist, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 7d89389 04/46: Make erc connect asynchronously, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 0d9709e 19/46: Meta + shift + Fn combos are recognized by xterm>=216., Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 5266c11 13/46: Allow more shell script defun forms, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 fbe5f7b 11/46: Completely ignore buffers with no name when copying file names, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 70244eb 15/46: Allow highlighting things like @math{2^{12}}, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 95d5520 12/46: Allow optional parameter to be nil, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 0780aa5 16/46: Replace XXX acronyms with draft standard ones, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 5f4c54b 18/46: Declare $ as an expression prefix in SCSS, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 344bc2b 17/46: Strip out some leading whitespace when looking at logs, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 69e0e89 23/46: Handle auth-source items with special characters on OS X,
Noam Postavsky <=
- [Emacs-diffs] scratch/backports-25.2 1cd6309 14/46: Allow ff-find-other-file (etc) to work with indirect clone buffers, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 5c084d9 10/46: Remove spurious newline in package list, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 80cf0b6 21/46: Restore the fix to bug#18527 from commit d6868025, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 51656da 28/46: Fix number-at-point in lisp buffers, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 0876366 43/46: Fix back-white <-> black-white typo, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 f3a19cf 31/46: Make a menu less ambiguous, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 12d1955 41/46: * lisp/files.el (version-control): Drop :group vc (Bug #14687), Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 cf54324 42/46: Improve error when installing non-package dirs, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 9e9f7c8 45/46: Don't --load directories, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 eb5dd2c 46/46: Don't require isearch-update before isearch-done, Noam Postavsky, 2016/10/02