From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 35443@debbugs.gnu.org
Subject: bug#35443: 27.0.50; Gnus (nnimap) shows "ghost" messages in summary buffer
Date: Fri, 12 Jul 2019 09:50:01 -0700 [thread overview]
Message-ID: <875zo7w62u.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <m3a7djuyjp.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 12 Jul 2019 16:18:02 +0200")
[-- Attachment #1: Type: text/plain, Size: 847 bytes --]
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> Which is obviously insufficient. I've since changed it to:
>>
>> "\\([A-Z][[:ascii:]-]+: \\)"
>>
>> Which works better, but also seems susceptible to breakage due to
>> ignorance. A quick scan doesn't turn up any `mail-header-regexp'
>> variables or `this-is-a-mail-header-p' functions -- does the above
>> regexp seem reasonable?
>
> Headers are case insensitive... but not all characters in the [:ascii:]
> set are allowed; far from it. [:alnum:] is closer, but with - and...
> er... stuff... One of the RFCs probably has the definition. :-)
Oh, good point. RFC2822 says chars 33 to 126, inclusive, minus the
colon. So I guess it's "[!-9,;-~]+: ", unlikely as some of those
characters seem.
Now I'm working with the attached diff.
Eric
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: imap-header-transform-fix.diff --]
[-- Type: text/x-patch, Size: 3916 bytes --]
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 9e52abc1ca..802254fc14 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -232,7 +232,7 @@ nnimap-retrieve-headers
(defun nnimap-transform-headers ()
(goto-char (point-min))
- (let (article lines size string labels)
+ (let (seen-articles article lines size string labels)
(cl-block nil
(while (not (eobp))
(while (not (looking-at "\\* [0-9]+ FETCH"))
@@ -261,45 +261,56 @@ nnimap-transform-headers
(and (re-search-forward "UID \\([0-9]+\\)" (line-end-position)
t)
(match-string 1)))
- (setq lines nil)
- (beginning-of-line)
- (setq size
- (and (re-search-forward "RFC822.SIZE \\([0-9]+\\)"
- (line-end-position)
- t)
- (match-string 1)))
- (beginning-of-line)
- (when (search-forward "X-GM-LABELS" (line-end-position) t)
- (setq labels (ignore-errors (read (current-buffer)))))
- (beginning-of-line)
- (when (search-forward "BODYSTRUCTURE" (line-end-position) t)
- (let ((structure (ignore-errors
- (read (current-buffer)))))
- (while (and (consp structure)
- (not (atom (car structure))))
- (setq structure (car structure)))
- (setq lines (if (and
- (stringp (car structure))
- (equal (upcase (nth 0 structure)) "MESSAGE")
- (equal (upcase (nth 1 structure)) "RFC822"))
- (nth 9 structure)
- (nth 7 structure)))))
- (delete-region (line-beginning-position) (line-end-position))
- (insert (format "211 %s Article retrieved." article))
- (forward-line 1)
- (when size
- (insert (format "Chars: %s\n" size)))
- (when lines
- (insert (format "Lines: %s\n" lines)))
- (when labels
- (insert (format "X-GM-LABELS: %s\n" labels)))
- ;; Most servers have a blank line after the headers, but
- ;; Davmail doesn't.
- (unless (re-search-forward "^\r$\\|^)\r?$" nil t)
- (goto-char (point-max)))
- (delete-region (line-beginning-position) (line-end-position))
- (insert ".")
- (forward-line 1)))))
+ ;; If we've already got headers for this article, or this
+ ;; FETCH line doesn't provide headers for the article, skip
+ ;; it. See bug#35433.
+ (if (or (member article seen-articles)
+ (save-excursion
+ (forward-line)
+ (null (looking-at-p
+ "[!-9,;-~]+: "))))
+ (delete-region (line-beginning-position)
+ (1+ (line-end-position)))
+ (setq lines nil)
+ (beginning-of-line)
+ (setq size
+ (and (re-search-forward "RFC822.SIZE \\([0-9]+\\)"
+ (line-end-position)
+ t)
+ (match-string 1)))
+ (beginning-of-line)
+ (when (search-forward "X-GM-LABELS" (line-end-position) t)
+ (setq labels (ignore-errors (read (current-buffer)))))
+ (beginning-of-line)
+ (when (search-forward "BODYSTRUCTURE" (line-end-position) t)
+ (let ((structure (ignore-errors
+ (read (current-buffer)))))
+ (while (and (consp structure)
+ (not (atom (car structure))))
+ (setq structure (car structure)))
+ (setq lines (if (and
+ (stringp (car structure))
+ (equal (upcase (nth 0 structure)) "MESSAGE")
+ (equal (upcase (nth 1 structure)) "RFC822"))
+ (nth 9 structure)
+ (nth 7 structure)))))
+ (delete-region (line-beginning-position) (line-end-position))
+ (insert (format "211 %s Article retrieved." article))
+ (forward-line 1)
+ (when size
+ (insert (format "Chars: %s\n" size)))
+ (when lines
+ (insert (format "Lines: %s\n" lines)))
+ (when labels
+ (insert (format "X-GM-LABELS: %s\n" labels)))
+ ;; Most servers have a blank line after the headers, but
+ ;; Davmail doesn't.
+ (unless (re-search-forward "^\r$\\|^)\r?$" nil t)
+ (goto-char (point-max)))
+ (delete-region (line-beginning-position) (line-end-position))
+ (insert ".")
+ (forward-line 1)
+ (push article seen-articles))))))
(defun nnimap-unfold-quoted-lines ()
;; Unfold quoted {number} strings.
next prev parent reply other threads:[~2019-07-12 16:50 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-27 6:23 bug#35443: 27.0.50; Gnus (nnimap) shows "ghost" messages in summary buffer Ulrich Mueller
2019-04-27 15:03 ` Eric Abrahamsen
2019-04-27 15:49 ` Ulrich Mueller
2019-04-27 20:47 ` Eric Abrahamsen
2019-04-28 3:53 ` Ulrich Mueller
2019-04-29 0:43 ` Eric Abrahamsen
2019-05-09 17:27 ` Eric Abrahamsen
2019-05-09 19:03 ` Ulrich Mueller
2019-05-09 20:15 ` Eric Abrahamsen
2019-06-22 12:26 ` Lars Ingebrigtsen
2019-06-22 16:27 ` Eric Abrahamsen
2019-06-23 12:13 ` Lars Ingebrigtsen
2019-06-23 16:55 ` Eric Abrahamsen
2019-06-23 16:58 ` Lars Ingebrigtsen
2019-06-23 17:23 ` Eric Abrahamsen
2019-06-22 21:36 ` Eric Abrahamsen
2019-06-23 12:23 ` Lars Ingebrigtsen
2019-07-11 17:38 ` Eric Abrahamsen
2019-07-11 20:28 ` Eric Abrahamsen
2019-07-12 14:18 ` Lars Ingebrigtsen
2019-07-12 16:50 ` Eric Abrahamsen [this message]
2019-07-12 16:58 ` Eric Abrahamsen
2019-07-14 16:19 ` Eric Abrahamsen
2019-07-12 15:02 ` Lars Ingebrigtsen
2019-07-15 17:45 ` Eric Abrahamsen
2019-07-15 18:16 ` Lars Ingebrigtsen
2019-05-07 21:14 ` Eric Abrahamsen
2019-05-08 7:07 ` Ulrich Mueller
2019-05-07 20:34 ` Eric Abrahamsen
2019-05-08 15:18 ` Ulrich Mueller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875zo7w62u.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=35443@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.