aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorFilipp Gunbin2018-05-15 03:02:49 +0300
committerFilipp Gunbin2018-05-17 18:44:31 +0300
commit60ff8101449eea3a5ca4961299501efd83d011bd (patch)
tree9947d1ac9503a65842975bb560a78265c41bc9a9 /lisp
parent01120ec3d2eecd11e23f008feed020def7ea0e88 (diff)
downloademacs-60ff8101449eea3a5ca4961299501efd83d011bd.tar.gz
emacs-60ff8101449eea3a5ca4961299501efd83d011bd.zip
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')
-rw-r--r--lisp/auth-source.el12
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."
1000 1000
1001(defun auth-source-netrc-parse-next-interesting () 1001(defun auth-source-netrc-parse-next-interesting ()
1002 "Advance to the next interesting position in the current buffer." 1002 "Advance to the next interesting position in the current buffer."
1003 (skip-chars-forward "\t ")
1003 ;; If we're looking at a comment or are at the end of the line, move forward 1004 ;; If we're looking at a comment or are at the end of the line, move forward
1004 (while (or (looking-at "#") 1005 (while (or (eq (char-after) ?#)
1005 (and (eolp) 1006 (and (eolp)
1006 (not (eobp)))) 1007 (not (eobp))))
1007 (forward-line 1)) 1008 (forward-line 1)
1008 (skip-chars-forward "\t ")) 1009 (skip-chars-forward "\t ")))
1009 1010
1010(defun auth-source-netrc-parse-one () 1011(defun auth-source-netrc-parse-one ()
1011 "Read one thing from the current buffer." 1012 "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."
1015 (looking-at "\"\\([^\"]*\\)\"") 1016 (looking-at "\"\\([^\"]*\\)\"")
1016 (looking-at "\\([^ \t\n]+\\)")) 1017 (looking-at "\\([^ \t\n]+\\)"))
1017 (forward-char (length (match-string 0))) 1018 (forward-char (length (match-string 0)))
1018 (auth-source-netrc-parse-next-interesting) 1019 (prog1
1019 (match-string-no-properties 1))) 1020 (match-string-no-properties 1)
1021 (auth-source-netrc-parse-next-interesting))))
1020 1022
1021;; with thanks to org-mode 1023;; with thanks to org-mode
1022(defsubst auth-source-current-line (&optional pos) 1024(defsubst auth-source-current-line (&optional pos)