Subject: Bug of nnimap-find-expired-articles

From: OGAWA Hirofumi <[email-masked]>
Date: Sun, 18 Jan 2015 19:38:27 +0900

Hi,

nnimap-find-expired-articles expires wrong articles.

When I am using 'never in expire config, emails in the group should not
be expired. But nnmail-expired-article-p which is used by
nnimap-find-expired-articles returns nil for 'never, and
nnimap-find-expired-articles pass returned nil to decode-time to find
articles.

By using returned nil for decode-time, nnimap-find-expired-articles
returns articles before current time, and expires all emails wrongly.

The following patch is to fix this bug.

Thanks.

Gnus v5.13
GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.25)
 of 2015-01-13 on devron

`nnmail-expired-article-p' can return nil. But
`nnimap-find-expired-articles' doesn't handle nil properly.

---

 lisp/gnus/nnimap.el |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff -puN lisp/gnus/nnimap.el~nnimap-find-expired-articles-fix lisp/gnus/nnimap.el
--- emacs/lisp/gnus/nnimap.el~nnimap-find-expired-articles-fix	2014-12-12 22:04:41.587303247 +0900
+++ emacs-hirofumi/lisp/gnus/nnimap.el	2014-12-12 22:04:41.591303236 +0900
@@ -996,19 +996,20 @@ textual parts.")
 
 (defun nnimap-find-expired-articles (group)
   (let ((cutoff (nnmail-expired-article-p group nil nil)))
-    (with-current-buffer (nnimap-buffer)
-      (let ((result
-	     (nnimap-command
-	      "UID SEARCH SENTBEFORE %s"
-	      (format-time-string
-	       (format "%%d-%s-%%Y"
-		       (upcase
-			(car (rassoc (nth 4 (decode-time cutoff))
-				     parse-time-months))))
-	       cutoff))))
-	(and (car result)
-	     (delete 0 (mapcar #'string-to-number
-			       (cdr (assoc "SEARCH" (cdr result))))))))))
+    (when cutoff
+      (with-current-buffer (nnimap-buffer)
+	(let ((result
+	       (nnimap-command
+		"UID SEARCH SENTBEFORE %s"
+		(format-time-string
+		 (format "%%d-%s-%%Y"
+			 (upcase
+			  (car (rassoc (nth 4 (decode-time cutoff))
+				       parse-time-months))))
+		 cutoff))))
+	  (and (car result)
+	       (delete 0 (mapcar #'string-to-number
+				 (cdr (assoc "SEARCH" (cdr result)))))))))))

 (defun nnimap-find-article-by-message-id (group server message-id
_
-- 
OGAWA Hirofumi <[email-masked]>