Subject: bug#18198: Gnus fails to read ~/.newsrc with group names which are not symbols

From: Eric Abrahamsen <[email-masked]>
Date: Sat, 14 Feb 2015 18:41:41 +0800

Ivan Shmakov <[email-masked]> writes:

>>>>>> Lars Ingebrigtsen <[email-masked]> writes:
>>>>>> Ivan Shmakov <[email-masked]> writes:
>
> […]
>
>  >> Here, the “group” field of .newsrc is read as an Emacs Lisp
>  >> expression.  Which may result either in an error, or, in the case of
>  >> [Hello]/World – and, similarly, (Hello)/World – in only the leading
>  >> [Hello] or (Hello) being actually read.
>
>  > Well, "[Hello]/World" isn't a valid newsgroup name,
>
> 	Yet (Hello)/World is.  (Per the newsgroup-name and wildmat-exact
> 	productions given in section 9.8 of RFC 3977.)
>
>  > and I think only newsgroups are supposed to be in ~/.newsrc?  How did
>  > you get such a group name there?
>
> 	I didn’t.  The person who brought this issue to IRC has
> 	apparently used something like (nnimap "imap.gmail.com") for
> 	gnus-select-method.
>
> 	Though indeed, I know of no reason /not/ to set
> 	gnus-save-newsrc-file to nil in this case.

This was discussed on the gnus.general list, and I produced a fix for it
(at least, I'm 95% sure it's the same issue), and then apparently never
sent the patch to the list, despite having thought I did. Attaching the
patch here.

Eric

>From cfb7b8feefeef69ed855e90f700aef6d1b7fda39 Mon Sep 17 00:00:00 2001
From: "Eric (clem)" <[email-masked]>
Date: Sat, 14 Feb 2015 18:39:10 +0800
Subject: [PATCH] Handle unquoted IMAP group names

* lisp/nnimap.el (nnimap-get-groups): Correctly read unquoted group
  names from the server LIST response.
---
 lisp/nnimap.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/nnimap.el b/lisp/nnimap.el
index d8b49f7..2d6a55e 100644
--- a/lisp/nnimap.el
+++ b/lisp/nnimap.el
@@ -1262,7 +1262,12 @@ If LIMIT, first try to limit the search to the N last articles."
     (while (search-forward "* LIST " nil t)
       (let ((flags (read (current-buffer)))
 	    (separator (read (current-buffer)))
-	    (group (read (current-buffer))))
+	    (group (buffer-substring-no-properties
+		    (progn (skip-chars-forward " \"")
+			   (point))
+		    (progn (move-end-of-line 1)
+			   (skip-chars-backward " 
\"")
+			   (point)))))
 	(unless (member '%NoSelect flags)
 	  (push (utf7-decode (if (stringp group)
 				 group
-- 
2.3.0