all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: 453@emacsbugs.donarmstrong.com
Subject: bug#453: 23.0.60; rfc822-bad-address: wrong-type-argument error
Date: Tue, 02 Sep 2008 18:07:57 +0200	[thread overview]
Message-ID: <871w02v8de.fsf@escher.local.home> (raw)
In-Reply-To: 87sksqa5gf.fsf@cyd.mit.edu

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	other threads:[~2008-09-02 16:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-26 21:30 bug#453: 23.0.60; rfc822-bad-address: wrong-type-argument error Chong Yidong
2008-08-27 10:38 ` Stephen Berman
2008-08-27 14:38   ` Chong Yidong
2008-09-02 16:07     ` Stephen Berman [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-06-20 15:34 Stephen Berman

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=871w02v8de.fsf@escher.local.home \
    --to=stephen.berman@gmx.net \
    --cc=453@emacsbugs.donarmstrong.com \
    --cc=cyd@stupidchicken.com \
    /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.