summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2010-03-08 11:17:30 -0500
committerChong Yidong <cyd@stupidchicken.com>2010-03-08 11:17:30 -0500
commit4e7cafbe337f4ea438a2b00a9cfeb84e6d744842 (patch)
tree211663f5628ddf4c80a1022cc2ff6805bbd39304
parentf7e0618c1371ef9fd39e585716966b82190998c1 (diff)
downloademacs-4e7cafbe337f4ea438a2b00a9cfeb84e6d744842.tar.gz
Additional fix for rfc822-addresses (Bug#5692).
* mail/rfc822.el (rfc822-addresses): Use nested catches to ensure that all errors are caught, and that the return value is always a list (Bug#5692).
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/mail/rfc822.el56
2 files changed, 36 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cc3683eaa78..04ba881c59e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2010-03-08 Chong Yidong <cyd@stupidchicken.com>
+
+ * mail/rfc822.el (rfc822-addresses): Use nested catches to ensure
+ that all errors are caught, and that the return value is always a
+ list (Bug#5692).
+
2010-03-08 Kenichi Handa <handa@m17n.org>
* language/misc-lang.el (windows-1256): New coding system.
diff --git a/lisp/mail/rfc822.el b/lisp/mail/rfc822.el
index 3048d56674b..2bdf16eff96 100644
--- a/lisp/mail/rfc822.el
+++ b/lisp/mail/rfc822.el
@@ -290,32 +290,36 @@
(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)))
- (rfc822-nuke-whitespace)
- (while (not (eobp))
- (setq rfc822-address-start (point))
- (setq tem
- (cond ((rfc822-looking-at ?\,)
- nil)
- ((looking-at "[][\000-\037@;:\\.>)]")
- (forward-char)
- (catch 'address ; this is for rfc822-bad-address
- (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)))
+ ;; Give `rfc822-address-start' a non-nil initial value to
+ ;; prevent `rfc822-bad-address' from raising a
+ ;; `wrong-type-argument' error.
+ (let* ((rfc822-address-start (point))
+ list tem
+ (err
+ (catch 'address
+ ;; Note that `rfc822-nuke-whitespace' and
+ ;; `rfc822-looking-at' can throw.
+ (rfc822-nuke-whitespace)
+ (while (not (eobp))
+ (setq rfc822-address-start (point))
+ (setq tem
+ (cond ((rfc822-looking-at ?\,)
+ nil)
+ ((looking-at "[][\000-\037@;:\\.>)]")
+ (forward-char)
+ (catch 'address ; For rfc822-bad-address
+ (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)))))
+ nil)))
+ (nreverse (append (if err (list err)) list))))
(and buf (kill-buffer buf))))))
(provide 'rfc822)