Mercurial > emacs
comparison lisp/mail/smtpmail.el @ 54350:e7ea873f6f2e
(smtpmail-read-response): Abort if process has
died to avoid infloop. Reported by Jonathan Glauner
<jglauner@sbum.org>.
author | Simon Josefsson <jas@extundo.com> |
---|---|
date | Thu, 11 Mar 2004 10:52:53 +0000 |
parents | 095e499a14ad |
children | 63ed691cfee6 |
comparison
equal
deleted
inserted
replaced
54349:e1815def2203 | 54350:e7ea873f6f2e |
---|---|
1 ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail | 1 ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail |
2 | 2 |
3 ;; Copyright (C) 1995, 1996, 2001, 2002, 2003 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp> | 5 ;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp> |
6 ;; Maintainer: Simon Josefsson <simon@josefsson.org> | 6 ;; Maintainer: Simon Josefsson <simon@josefsson.org> |
7 ;; w32 Maintainer: Brian D. Carlstrom <bdc@ai.mit.edu> | 7 ;; w32 Maintainer: Brian D. Carlstrom <bdc@ai.mit.edu> |
8 ;; ESMTP support: Simon Leinen <simon@switch.ch> | 8 ;; ESMTP support: Simon Leinen <simon@switch.ch> |
776 (let ((case-fold-search nil) | 776 (let ((case-fold-search nil) |
777 (response-strings nil) | 777 (response-strings nil) |
778 (response-continue t) | 778 (response-continue t) |
779 (return-value '(nil ())) | 779 (return-value '(nil ())) |
780 match-end) | 780 match-end) |
781 | 781 (catch 'done |
782 (while response-continue | 782 (while response-continue |
783 (goto-char smtpmail-read-point) | 783 (goto-char smtpmail-read-point) |
784 (while (not (search-forward "\r\n" nil t)) | 784 (while (not (search-forward "\r\n" nil t)) |
785 (accept-process-output process) | 785 (unless (memq (process-status process) '(open run)) |
786 (goto-char smtpmail-read-point)) | 786 (throw 'done nil)) |
787 | 787 (accept-process-output process) |
788 (setq match-end (point)) | 788 (goto-char smtpmail-read-point)) |
789 (setq response-strings | 789 |
790 (cons (buffer-substring smtpmail-read-point (- match-end 2)) | 790 (setq match-end (point)) |
791 response-strings)) | 791 (setq response-strings |
792 | 792 (cons (buffer-substring smtpmail-read-point (- match-end 2)) |
793 (goto-char smtpmail-read-point) | 793 response-strings)) |
794 (if (looking-at "[0-9]+ ") | 794 |
795 (let ((begin (match-beginning 0)) | 795 (goto-char smtpmail-read-point) |
796 (end (match-end 0))) | 796 (if (looking-at "[0-9]+ ") |
797 (if smtpmail-debug-info | 797 (let ((begin (match-beginning 0)) |
798 (message "%s" (car response-strings))) | 798 (end (match-end 0))) |
799 | 799 (if smtpmail-debug-info |
800 (setq smtpmail-read-point match-end) | 800 (message "%s" (car response-strings))) |
801 | 801 |
802 ;; ignore lines that start with "0" | 802 (setq smtpmail-read-point match-end) |
803 (if (looking-at "0[0-9]+ ") | 803 |
804 nil | 804 ;; ignore lines that start with "0" |
805 (if (looking-at "0[0-9]+ ") | |
806 nil | |
807 (setq response-continue nil) | |
808 (setq return-value | |
809 (cons (string-to-int | |
810 (buffer-substring begin end)) | |
811 (nreverse response-strings))))) | |
812 | |
813 (if (looking-at "[0-9]+-") | |
814 (progn (if smtpmail-debug-info | |
815 (message "%s" (car response-strings))) | |
816 (setq smtpmail-read-point match-end) | |
817 (setq response-continue t)) | |
818 (progn | |
819 (setq smtpmail-read-point match-end) | |
805 (setq response-continue nil) | 820 (setq response-continue nil) |
806 (setq return-value | 821 (setq return-value |
807 (cons (string-to-int | 822 (cons nil (nreverse response-strings))))))) |
808 (buffer-substring begin end)) | 823 (setq smtpmail-read-point match-end)) |
809 (nreverse response-strings))))) | |
810 | |
811 (if (looking-at "[0-9]+-") | |
812 (progn (if smtpmail-debug-info | |
813 (message "%s" (car response-strings))) | |
814 (setq smtpmail-read-point match-end) | |
815 (setq response-continue t)) | |
816 (progn | |
817 (setq smtpmail-read-point match-end) | |
818 (setq response-continue nil) | |
819 (setq return-value | |
820 (cons nil (nreverse response-strings))) | |
821 ) | |
822 ))) | |
823 (setq smtpmail-read-point match-end) | |
824 return-value)) | 824 return-value)) |
825 | 825 |
826 | 826 |
827 (defun smtpmail-send-command (process command) | 827 (defun smtpmail-send-command (process command) |
828 (goto-char (point-max)) | 828 (goto-char (point-max)) |