[gnus git] branch master updated: m0-7-118-g0747a49 =1= When a data token is "machine", abort parsing the current line.

Ted Zlatanov <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  0747a49b4012e3667a90a2b9b78a88462b405f16 (commit)
      from  00222362844ced15662ee8ed81388c3940ceb309 (commit)


- Log -----------------------------------------------------------------
commit 0747a49b4012e3667a90a2b9b78a88462b405f16
Author: Ted Zlatanov <[email protected]>
Date:   Mon Jun 17 19:24:59 2013 -0400

    When a data token is "machine", abort parsing the current line.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e8b070c..3cf303a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2013-06-17  Teodor Zlatanov  <[email protected]>
+
+	* auth-source.el (auth-source-current-line): New function.
+	(auth-source-netrc-parse-entries): When a data token is "machine",
+	assume we're in the wrong place and abort parsing the current line.
+
 2013-06-17  Lars Magne Ingebrigtsen  <[email protected]>
 
 	* eww.el (eww-tag-select): Don't render totally empty <select> forms.
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index c3eb6db..a382419 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1065,6 +1065,13 @@ Note that the MAX parameter is used so we can exit the parse early."
     (auth-source-netrc-parse-next-interesting)
     (match-string-no-properties 1)))
 
+;; with thanks to org-mode
+(defsubst auth-source-current-line (&optional pos)
+  (save-excursion
+    (and pos (goto-char pos))
+    ;; works also in narrowed buffer, because we start at 1, not point-min
+    (+ (if (bolp) 1 0) (count-lines 1 (point)))))
+
 (defun auth-source-netrc-parse-entries(check max)
   "Parse up to MAX netrc entries, passed by CHECK, from the current buffer."
   (let ((adder (lambda(check alist all)
@@ -1081,6 +1088,8 @@ Note that the MAX parameter is used so we can exit the parse early."
       (when (and alist
                  (or default
                      (equal item "machine")))
+        (auth-source-do-trivia
+         "auth-source-netrc-parse-entries: got entry %S" alist)
         (setq all (funcall adder check alist all)
               alist nil))
       ;; In default entries, we don't have a next token.
@@ -1089,11 +1098,21 @@ Note that the MAX parameter is used so we can exit the parse early."
           (push (cons "machine" t) alist)
         ;; Not a default entry.  Grab the next item.
         (when (setq item2 (auth-source-netrc-parse-one))
-          (push (cons item item2) alist))))
+          ;; Did we get a "machine" value?
+          (if (equal item2 "machine")
+              (progn
+                (gnus-error 1
+                 "%s: Unexpected 'machine' token at line %d"
+                 "auth-source-netrc-parse-entries"
+                 (auth-source-current-line))
+                (forward-line 1))
+            (push (cons item item2) alist)))))
 
     ;; Clean up: if there's an entry left over, use it.
     (when alist
-      (setq all (funcall adder check alist all)))
+      (setq all (funcall adder check alist all))
+      (auth-source-do-trivia
+       "auth-source-netrc-parse-entries: got2 entry %S" alist))
     (nreverse all)))
 
 (defvar auth-source-passphrase-alist nil)

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog      |    6 ++++++
 lisp/auth-source.el |   23 +++++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.