Re: smtp-end-of-line for SMTP over SSL
Hiroya Murata <[email protected]> Wed, 15 Feb 2006 13:10:06 +0900
| Newsgroups | gmane.mail.wanderlust.general.japanese,gmane.mail.emacs.mime.japanese |
|---|---|
| Message-ID | <u1wy5gt41.wl%[email protected]> |
;; 一応 emacs-mime-ja にも振っておきます. In the message [Wanderlust : No.13899] on Sat, 11 Feb 2006 21:13:26 +0900, Daiki Ueno wrote: > > smtp-end-of-line を設定しないと, smtp-read-response で openssl の > > 出力から始まって本来の応答 (220 で始まる行) を含めてブロックとして > > 処理されるので, それ全体が捨てられてしまい, それ以降の応答がないの > > で, 待ちになってしまっていました. > > smtp-end-of-line を設定すると, 応答の末尾を探す処理で, openssl の > > 出力も順に処理され, 応答コードがないので捨てられているみたいです. > うーん。なるほど。 > しかし、この動作は意図されたものではないと思います。 > > ですので, smtp-read-response で, "[1-5][0-9][0-9][ -]" で始まらな > > い行を捨てる様にしてみると, ちゃんと送信出来ました. > smtp.el の立場では、送信は厳格・受信は寛容の原則から、 > 1. サーバから送られてきた改行コードは正規化して扱う > 2. "[1-5][0-9][0-9][ -]" で始まらない行を捨てる > のは正しい判断だと思います。 以前のパッチは 1. について中途半端だったので, その点について見直し た変更をしてみました. パッチを添付します. このパッチで問題がなければ, flim-1_14 に commit しますが, 宜しいで しょうか? -- Hiroya Murata (村田 浩也) <[email protected]> PGP fingerprint: 53B6 1B4A 8193 A2D4 1526 BC9E 9AEF 2F6D 249D 5F17
smtp.el.diff
(application/octet-stream, 1.8 KB)
Index: smtp.el
===================================================================
RCS file: /cvs/root/flim/smtp.el,v
retrieving revision 1.5.2.22
diff -u -w -r1.5.2.22 smtp.el
--- smtp.el 25 Jul 2005 01:51:09 -0000 1.5.2.22
+++ smtp.el 15 Feb 2006 04:01:48 -0000
@@ -653,26 +653,29 @@
response)
(while response-continue
(goto-char smtp-read-point)
- (while (not (search-forward smtp-end-of-line nil t))
+ (while (not (re-search-forward "\r?\n" nil t))
(unless (smtp-connection-opened connection)
(signal 'smtp-error "Connection closed"))
(accept-process-output (smtp-connection-process-internal connection))
(goto-char smtp-read-point))
- (if decoder
- (let ((string (buffer-substring smtp-read-point (- (point) 2))))
- (delete-region smtp-read-point (point))
- (insert (funcall decoder string) smtp-end-of-line)))
+ (let ((bol smtp-read-point)
+ (eol (match-beginning 0))
+ (reply-code nil))
+ (setq smtp-read-point (match-end 0))
+ (goto-char bol)
+ (when (looking-at "[1-5][0-9][0-9]\\([ -]\\)")
+ (when (string= (match-string 1) " ")
+ (setq reply-code (read (point-marker))))
+ (when decoder
+ (let ((string (buffer-substring bol eol)))
+ (delete-region bol eol)
+ (insert (funcall decoder string))))
(setq response
(nconc response
- (list (buffer-substring
- (+ 4 smtp-read-point)
- (- (point) 2)))))
- (goto-char
- (prog1 smtp-read-point
- (setq smtp-read-point (point))))
- (if (looking-at "[1-5][0-9][0-9] ")
- (setq response (cons (read (point-marker)) response)
- response-continue nil)))
+ (list (buffer-substring (+ 4 bol) eol))))
+ (when reply-code
+ (setq response (cons reply-code response)
+ response-continue nil)))))
response))
(defun smtp-send-command (connection command)