bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#453: 23.0.60; rfc822-bad-address: wrong-type-argument error


From: Stephen Berman
Subject: bug#453: 23.0.60; rfc822-bad-address: wrong-type-argument error
Date: Tue, 02 Sep 2008 18:07:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

On Wed, 27 Aug 2008 10:38:24 -0400 Chong Yidong <cyd@stupidchicken.com> wrote:

> Stephen Berman <stephen.berman@gmx.net> writes:
>
>> 1. bbdb-rfc822-addresses is trying to parse this header:
>>    (""Groß, Werner"") <W.F.Gross@t-online.de>
>>    which presumably violates RFC822.
>> 2. bbdb-rfc822-addresses calls rfc822-addresses, which turns the header
>>    into this string:
>>    (""Groß
>>    and, after let-binding but before setq-ing rfc822-address-start,
>> 3. calls rfc822-nuke-whitespace, which further truncates the header to:
>>    (
>>    and then calls
>> 4. rfc822-bad-address, which tries to call narrow-to-region with
>>    rfc822-address-start, which is still nil, as the beginning of the
>>    region: BZZT!
>
> Now I understand.  could you send a new patch?  Thanks.

I was going to just resend my patch minus the inappropriate white space
changes.  But upon reconsideration, I'm not confident that the patch I
sent previously DTRT.  I'm not even sure what TRT is here: as I wrote in
my OP, my patch returns an error string as specified by
rfc822-bad-address, but the caller bbdb-rfc822-addresses expects a list,
so it still raises a wrong-type error.  This happens when the relocated
catch sexp has scope to the end of the let that immediately encloses it
(patch (i) below).  But I leave the catch in its existing position and
move rfc822-nuke-whitespace to within it (patch (ii) below), then no
error is raised, but also there's no indication of a bad address; yet
stepping through the code with edebug does pass through
rfc822-bad-address.  So where should the catch be located?  Hopefully
someone familiar (unlike me) with RFC 822 and rfc822.el, and ideally
also bbdb-rfc822-addresses, can answer that question and say whether
either of these patches is suitable, or provide a better one.

Steve Berman

Patch (i) (returns an error string as specified by rfc822-bad-address,
but raises a wrong-type error with bbdb-rfc822-addresses):

*** emacs/lisp/mail/rfc822.el.~1.28.~   2008-05-06 17:54:09.000000000 +0200
--- emacs/lisp/mail/rfc822.el   2008-09-02 17:35:28.000000000 +0200
***************
*** 292,303 ****
          (goto-char (point-min))
          (let ((list ())
                tem
!               rfc822-address-start); this is for rfc822-bad-address
!           (rfc822-nuke-whitespace)
!           (while (not (eobp))
!             (setq rfc822-address-start (point))
!             (setq tem
!                   (catch 'address ; this is for rfc822-bad-address
                      (cond ((rfc822-looking-at ?\,)
                             nil)
                            ((looking-at "[][\000-\037@;:\\.>)]")
--- 292,306 ----
          (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@;:\\.>)]")
***************
*** 306,318 ****
                               (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))))))
  
  (provide 'rfc822)
--- 309,321 ----
                               (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))))))
  
  (provide 'rfc822)

Patch (ii) (bbdb-rfc822-addresses raises no error, but also there's no
indication of a bad address; yet stepping through the code with edebug
does pass through rfc822-bad-address):

*** emacs/lisp/mail/rfc822.el.~1.28.~   2008-05-06 17:54:09.000000000 +0200
--- emacs/lisp/mail/rfc822.el   2008-09-02 18:01:49.000000000 +0200
***************
*** 293,312 ****
          (let ((list ())
                tem
                rfc822-address-start); this is for rfc822-bad-address
-           (rfc822-nuke-whitespace)
            (while (not (eobp))
              (setq rfc822-address-start (point))
              (setq tem
                    (catch 'address ; this is for rfc822-bad-address
!                     (cond ((rfc822-looking-at ?\,)
!                            nil)
!                           ((looking-at "[][\000-\037@;:\\.>)]")
!                            (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)))
--- 293,313 ----
          (let ((list ())
                tem
                rfc822-address-start); this is for rfc822-bad-address
            (while (not (eobp))
              (setq rfc822-address-start (point))
              (setq tem
                    (catch 'address ; this is for rfc822-bad-address
!                     (progn
!                       (rfc822-nuke-whitespace)
!                       (cond ((rfc822-looking-at ?\,)
!                              nil)
!                             ((looking-at "[][\000-\037@;:\\.>)]")
!                              (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)))






reply via email to

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