comparison lisp/mail/rfc822.el @ 107357:0f6a30c8d91a

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).
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 08 Mar 2010 11:17:30 -0500
parents 1cbedcbd728f
children 376148b31b5e
comparison
equal deleted inserted replaced
107356:76b07c83bb0f 107357:0f6a30c8d91a
288 (while (re-search-forward "\\([^\\]\\(\\\\\\\\\\)*\\)\n[ \t]" 288 (while (re-search-forward "\\([^\\]\\(\\\\\\\\\\)*\\)\n[ \t]"
289 nil t) 289 nil t)
290 (replace-match "\\1 " t)) 290 (replace-match "\\1 " t))
291 291
292 (goto-char (point-min)) 292 (goto-char (point-min))
293 (let ((list ()) 293 ;; Give `rfc822-address-start' a non-nil initial value to
294 tem 294 ;; prevent `rfc822-bad-address' from raising a
295 ;; This is for rfc822-bad-address. Give it a non-nil 295 ;; `wrong-type-argument' error.
296 ;; initial value to prevent rfc822-bad-address from 296 (let* ((rfc822-address-start (point))
297 ;; raising a wrong-type-argument error 297 list tem
298 (rfc822-address-start (point))) 298 (err
299 (rfc822-nuke-whitespace) 299 (catch 'address
300 (while (not (eobp)) 300 ;; Note that `rfc822-nuke-whitespace' and
301 (setq rfc822-address-start (point)) 301 ;; `rfc822-looking-at' can throw.
302 (setq tem 302 (rfc822-nuke-whitespace)
303 (cond ((rfc822-looking-at ?\,) 303 (while (not (eobp))
304 nil) 304 (setq rfc822-address-start (point))
305 ((looking-at "[][\000-\037@;:\\.>)]") 305 (setq tem
306 (forward-char) 306 (cond ((rfc822-looking-at ?\,)
307 (catch 'address ; this is for rfc822-bad-address 307 nil)
308 (rfc822-bad-address 308 ((looking-at "[][\000-\037@;:\\.>)]")
309 (format "Strange character \\%c found" 309 (forward-char)
310 (preceding-char))))) 310 (catch 'address ; For rfc822-bad-address
311 (t 311 (rfc822-bad-address
312 (rfc822-addresses-1 t)))) 312 (format "Strange character \\%c found"
313 (cond ((null tem)) 313 (preceding-char)))))
314 ((stringp tem) 314 (t
315 (setq list (cons tem list))) 315 (rfc822-addresses-1 t))))
316 (t 316 (cond ((null tem))
317 (setq list (nconc (nreverse tem) list))))) 317 ((stringp tem)
318 (nreverse list))) 318 (setq list (cons tem list)))
319 (t
320 (setq list (nconc (nreverse tem) list)))))
321 nil)))
322 (nreverse (append (if err (list err)) list))))
319 (and buf (kill-buffer buf)))))) 323 (and buf (kill-buffer buf))))))
320 324
321 (provide 'rfc822) 325 (provide 'rfc822)
322 326
323 ;; arch-tag: 5d388a24-e173-40fb-9b8e-85269de44b37 327 ;; arch-tag: 5d388a24-e173-40fb-9b8e-85269de44b37