info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems with splitting and imap


From: Ted Zlatanov
Subject: Re: problems with splitting and imap
Date: Tue, 21 Jul 2009 11:00:38 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux)

On Tue, 21 Jul 2009 00:04:43 +0200 Richard Riley <address@hidden> wrote: 

RR> Ted Zlatanov <address@hidden> writes:
>> On Mon, 20 Jul 2009 12:13:44 -0500 Ted Zlatanov <address@hidden> wrote: 
>> 
TZ> On Sun, 19 Jul 2009 15:31:09 +0200 Richard Riley <address@hidden> wrote: 
RR> A couple of days ago I had to remove all my splitting code because of
RR> this error:
>> 
RR> ,----
RR> | Debugger entered--Lisp error: (wrong-type-argument listp "(Unparsable 
address -- Strange character \\> found: \">_^_\")")
RR> |   bbdb/gnus-split-method()
RR> |   nnimap-split-to-groups(bbdb/gnus-split-method)
RR> |   nnimap-split-articles(nil "mymail")
RR> |   nnimap-request-scan(nil "mymail")
RR> |   gnus-request-scan(nil (nnimap "mymail" (nnimap-stream ssl) 
(nnimap-address "imap.richardriley.net") (nnimap-authinfo-file "~/.authinfo") 
(nnir-search-engine imap)))
RR> |   gnus-read-active-file-1((nnimap "mymail" (nnimap-stream ssl) 
(nnimap-address "imap.richardriley.net") (nnimap-authinfo-file "~/.authinfo") 
(nnir-search-engine imap)) nil)
RR> |   gnus-read-active-file()
RR> |   gnus-group-get-new-news(nil)
RR> |   gnus-1(nil nil nil)
RR> |   gnus(nil)
RR> |   call-interactively(gnus nil nil)
RR> `----
>> 
RR> Could someone please suggest how to fix this/locate the offending message?
>> 
RR> I'm talking to a dovecot IMAP server btw.
>> 
TZ> Looks like a bug in bbdb/gnus-split-method.  It should return nil if
TZ> this error happens (or maybe do something smarter, I don't know the code
TZ> too well so I didn't write a patch).  The error is coming from
TZ> `rfc822-addresses' which is part of Emacs.
>> 
TZ> I am cc-ing the BBDB group for help.
>> 
>> Sorry, the first CC didn't work.  Retrying.  This may get hairy because
>> gnu.emacs.gnus is a newsgroup.  I also cc-ed the Ding mailing list for
>> Gnus, so replies from BBDB developers make it back to Gnus developers.
>> 
>> Ted

RR> Thanks Ted.

RR> I have to had to remove all splitting client side for the moment :-(

RR> But even a hint as to how to catch the offending mail would be a great
RR> help.

You can catch the offender by redefining rfc822.el functions.  This is
rfc822-addresses:

(defun rfc822-addresses (header-text)
  (if (string-match "\\`[ \t]*\\([^][\000-\037 ()<>@,;:\\\".]+\\)[ \t]*\\'"
                    header-text)
      ;; Make very simple case moderately fast.
      (list (substring header-text (match-beginning 1) (match-end 1)))
    (let ((buf (generate-new-buffer " rfc822")))
      (unwind-protect
        (save-excursion
          (set-buffer buf)
          (make-local-variable 'case-fold-search)
          (setq case-fold-search nil)   ;For speed(?)
          (insert header-text)
          ;; unfold continuation lines
          (goto-char (point-min))

          (while (re-search-forward "\\([^\\]\\(\\\\\\\\\\)*\\)\n[ \t]" nil t)
            (replace-match "\\1 " t))

          (goto-char (point-min))
          (let ((list ())
                tem
                ;; This is for rfc822-bad-address.  Give it a non-nil
                ;; initial value to prevent rfc822-bad-address from
                ;; raising a wrong-type-argument error
                (rfc822-address-start (point)))
            (catch 'address ; this is for rfc822-bad-address
              (rfc822-nuke-whitespace)
              (while (not (eobp))
                (setq rfc822-address-start (point))
                (setq tem
                      (cond ((rfc822-looking-at ?\,)
                             nil)
                            ((looking-at "[][\000-\037@;:\\.>)]")
                             (debug "list so far %s, remaining text %s" list 
(buffer-substring (point) (point-max)) ; *** debug ***
                             (forward-char)
                             (rfc822-bad-address
                               (format "Strange character \\%c found"
                                       (preceding-char))))
                            (t
                             (rfc822-addresses-1 t))))
                (cond ((null tem))
                      ((stringp tem)
                       (setq list (cons tem list)))
                      (t
                       (setq list (nconc (nreverse tem) list)))))
              (nreverse list))))
        (and buf (kill-buffer buf))))))

Note the single debug statement I inserted.  Hit `C-x C-e' after the
last parenthesis to use this function; copy it into the *scratch* buffer
to keep playing with it.

You'll see a stack popup buffer now every time the function moves
through an address list.  Just follow along to find the breaking point
(`c' continues, `q' quits).  It's the address following the last
successful one, in "remaining text."  You can get much fancier here
(e.g. show the current content) but I want to show you the very basics
of debugging.  Basically you're seeing this, I think, because there's
one of the characters listed above the debug statement (brackets, octal
0-037, @;:\.>, closing parenthesis) where one shouldn't be.  The BBDB
function it assumes a particular format for the return of
`rfc822-addresses' and breaks when that format is not observed if one of
the addresses has an invalid character as described above.

Ted


reply via email to

[Prev in Thread] Current Thread [Next in Thread]