diff options
author | Filipp Gunbin <fgunbin@fastmail.fm> | 2018-05-15 03:02:49 +0300 |
---|---|---|
committer | Filipp Gunbin <fgunbin@fastmail.fm> | 2018-05-17 18:44:31 +0300 |
commit | 60ff8101449eea3a5ca4961299501efd83d011bd (patch) | |
tree | 9947d1ac9503a65842975bb560a78265c41bc9a9 /lisp/auth-source.el | |
parent | 01120ec3d2eecd11e23f008feed020def7ea0e88 (diff) | |
download | emacs-60ff8101449eea3a5ca4961299501efd83d011bd.tar.gz |
Fix bugs in `auth-source-netrc-parse-one'.
* lisp/auth-source.el (auth-source-netrc-parse-one): Ensure that match
data is not overwritten in `auth-source-netrc-parse-next-interesting'.
Ensure that blanks are skipped before and after going over comments
and eols.
* test/lisp/auth-source-tests.el (auth-source-test-netrc-parse-one): New test.
Diffstat (limited to 'lisp/auth-source.el')
-rw-r--r-- | lisp/auth-source.el | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el index 918d785eaef..abff0def95f 100644 --- a/lisp/auth-source.el +++ b/lisp/auth-source.el @@ -1000,12 +1000,13 @@ Note that the MAX parameter is used so we can exit the parse early." (defun auth-source-netrc-parse-next-interesting () "Advance to the next interesting position in the current buffer." + (skip-chars-forward "\t ") ;; If we're looking at a comment or are at the end of the line, move forward - (while (or (looking-at "#") + (while (or (eq (char-after) ?#) (and (eolp) (not (eobp)))) - (forward-line 1)) - (skip-chars-forward "\t ")) + (forward-line 1) + (skip-chars-forward "\t "))) (defun auth-source-netrc-parse-one () "Read one thing from the current buffer." @@ -1015,8 +1016,9 @@ Note that the MAX parameter is used so we can exit the parse early." (looking-at "\"\\([^\"]*\\)\"") (looking-at "\\([^ \t\n]+\\)")) (forward-char (length (match-string 0))) - (auth-source-netrc-parse-next-interesting) - (match-string-no-properties 1))) + (prog1 + (match-string-no-properties 1) + (auth-source-netrc-parse-next-interesting)))) ;; with thanks to org-mode (defsubst auth-source-current-line (&optional pos) |