* dgnushack.el: Autoload sha1 on XEmacs.
[gnus] / lisp / pop3.el
index 3ca5cab..90e11b3 100644 (file)
@@ -302,11 +302,11 @@ Returns the process associated with the connection."
                    ((or (eq pop3-stream-type 'ssl)
                         (and (not pop3-stream-type)
                              (member port '(995 "pop3s"))))
-                    :tls)
+                    'tls)
                    (t
                     (or pop3-stream-type 'network)))
             :capability-command "CAPA\r\n"
-            :end-of-command "^\\.\r?\n\\|^\\+[A-Z]+ .*\n"
+            :end-of-command "^\\.\r?\n\\|^\\(-ERR\\|+OK \\).*\n"
             :success "^\\+OK.*\n"
             :return-list t
             :starttls-function
@@ -319,6 +319,7 @@ Returns the process associated with the connection."
                (substring response (or (string-match "<" response) 0)
                           (+ 1 (or (string-match ">" response) -1)))))
        (pop3-set-process-query-on-exit-flag (car result) nil)
+       (erase-buffer)
        (car result)))))
 
 ;; Support functions
@@ -514,6 +515,8 @@ Otherwise, return the size of the message-id MSG"
   (let ((start pop3-read-point) end)
     (with-current-buffer (process-buffer process)
       (while (not (re-search-forward "^\\.\r\n" nil t))
+       (unless (memq (process-status process) '(open run))
+         (error "pop3 server closed the connection"))
        (pop3-accept-process-output process)
        (goto-char start))
       (setq pop3-read-point (point-marker))