[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
nnimap 0.89 -> 0.90 patches
Index: nnimap/ChangeLog
diff -c nnimap/ChangeLog:1.162 nnimap/ChangeLog:1.166
*** nnimap/ChangeLog:1.162 Sat Dec 26 13:06:48 1998
--- nnimap/ChangeLog Mon Jan 4 13:49:56 1999
***************
*** 1,3 ****
--- 1,43 ----
+ 1999-01-04 22:46:52 Simon Josefsson <jas@pdc.kth.se>
+
+ * nnimap 0.90 released.
+
+ 1999-01-04 22:39:05 Simon Josefsson <jas@pdc.kth.se>
+
+ * imap.el (imap-response-data-fetch): Parse everything before
+ setting.
+
+ 1999-01-04 18:22:30 Simon Josefsson <jas@pdc.kth.se>
+
+ * nnimap.el (nnimap-request-update-info-internal): Look in flags,
+ not list-flags.
+
+ 1999-01-03 00:14:51 Simon Josefsson <jas@pdc.kth.se>
+
+ * nnimap.el (nnimap-request-list-mapper): Look in list-flags, not
+ flags.
+
+ 1999-01-02 21:22:03 Simon Josefsson <jas@pdc.kth.se>
+
+ * imap.el (imap-parse-mailbox): Turn symbols into strings.
+
+ 1999-01-02 20:06:04 Simon Josefsson <jas@pdc.kth.se>
+
+ * nnimap.el (nnimap-close-server): Don't kill imap buffer.
+
+ 1999-01-02 20:04:32 Simon Josefsson <jas@pdc.kth.se>
+
+ * imap.el (imap-buffer-list): Removed.
+ (imap-open): Don't use imap-buffer-list. Protect against
+ man-in-the-middle attacks on authenticator capability.
+
+ 1998-12-27 22:58:19 Simon Josefsson <jas@pdc.kth.se>
+
+ * imap.el (imap-ssl-open-1): Use imap-parse-greeting.
+ (imap-namespace): Fix.
+ (imap-parse-mailbox): Use imap-parse-astring.
+ (imap-response-data-text-code): Conditional parse.
+
1998-12-26 22:04:14 Simon Josefsson <jas@pdc.kth.se>
* nnimap 0.89 released.
Index: nnimap/imap.el
diff -c nnimap/imap.el:1.96 nnimap/imap.el:1.104
*** nnimap/imap.el:1.96 Sat Dec 26 12:49:02 1998
--- nnimap/imap.el Mon Jan 4 13:44:52 1999
***************
*** 2,7 ****
--- 2,9 ----
;; Copyright (C) 1998 Free Software Foundation, Inc.
;; Author: Simon Josefsson <jas@pdc.kth.se>
+ ;; Keywords: mail
+
;; This file is not part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
***************
*** 37,54 ****
--- 39,63 ----
;;
;; (imap-open "my.mail.server")
;; " *imap* my.mail.server:0"
+ ;;
;; (imap-authenticate " *imap* my.mail.server:0")
;; auth
+ ;;
;; (imap-mailbox-lsub " *imap* my.mail.server:0")
;; ("INBOX.sentmail" "INBOX.private" "INBOX.draft" "INBOX.spam")
+ ;;
;; (imap-mailbox-list " *imap* my.mail.server:0" "INBOX.n%")
;; ("INBOX.ntbugtraq" "INBOX.nymb" "INBOX.netboot" "INBOX.nnimap")
+ ;;
;; (imap-mailbox-select "INBOX.nnimap" " *imap* my.mail.server:0")
;; "INBOX.nnimap"
+ ;;
;; (imap-mailbox-get 'exists nil " *imap* my.mail.server:0")
;; 39
+ ;;
;; (imap-search "FLAGGED SINCE 18-DEC-98" " *imap* my.mail.server:0")
;; (235 236)
+ ;;
;; xxx: more examples
;;
;; Server functions:
***************
*** 229,238 ****
;; Internal variables.
- (defvar imap-buffer-list nil
- "List of buffers the imap library has created, which are destroyed
- on call to `imap-done'.")
-
(defvar imap-stream nil)
(defvar imap-auth nil)
(defvar imap-server nil)
--- 238,243 ----
***************
*** 376,387 ****
(with-current-buffer buffer
(goto-char (point-min))
(while (and (memq (process-status proc) '(open run))
! (goto-char (point-min))
! (not (re-search-forward "^\r*\\* OK" nil t)))
(accept-process-output proc 1)
! (goto-char (point-min)))
! (beginning-of-line)
! (delete-region (point-min) (point))
(when (memq (process-status proc) '(open run))
proc))))
--- 381,398 ----
(with-current-buffer buffer
(goto-char (point-min))
(while (and (memq (process-status proc) '(open run))
! (goto-char (point-max))
! (forward-line -1)
! (not (imap-parse-greeting)))
(accept-process-output proc 1)
! (sit-for 1))
! (and imap-log
! (with-current-buffer (get-buffer-create imap-log)
! (imap-disable-multibyte)
! (buffer-disable-undo)
! (goto-char (point-max))
! (insert-buffer buffer)))
! (erase-buffer)
(when (memq (process-status proc) '(open run))
proc))))
***************
*** 416,422 ****
(make-variable-buffer-local 'imap-username)
(make-variable-buffer-local 'imap-password)
(let (user passwd ret)
! (condition-case ()
(while (or (not user) (not passwd))
(setq user (or imap-username
(read-from-minibuffer
--- 427,433 ----
(make-variable-buffer-local 'imap-username)
(make-variable-buffer-local 'imap-password)
(let (user passwd ret)
! ;; (condition-case ()
(while (or (not user) (not passwd))
(setq user (or imap-username
(read-from-minibuffer
***************
*** 437,445 ****
(message "Login failed...")
(setq passwd nil)
(sit-for 1))))
! (quit (with-current-buffer buffer
! (setq user nil
! passwd nil))))
ret)))
(defun imap-kerberos4a-p (buffer)
--- 448,459 ----
(message "Login failed...")
(setq passwd nil)
(sit-for 1))))
! ;; (quit (with-current-buffer buffer
! ;; (setq user nil
! ;; passwd nil)))
! ;; (error (with-current-buffer buffer
! ;; (setq user nil
! ;; passwd nil))))
ret)))
(defun imap-kerberos4a-p (buffer)
***************
*** 516,557 ****
available authenticators. If nil, it choices the best stream the
server is capable of.
BUFFER can be a buffer or a name of a buffer, which is created if
! necessery."
(setq buffer (or buffer (format " *imap* %s:%d" server (or port 0))))
- (unless (get-buffer buffer)
- (setq imap-buffer-list (cons buffer imap-buffer-list)))
(with-current-buffer (get-buffer-create buffer)
! (let (stream-changed)
! (if (imap-opened buffer)
(imap-close buffer)
- (mapc 'make-variable-buffer-local imap-local-variables)
- (imap-disable-multibyte)
- (buffer-disable-undo))
- (if server (setq imap-server server))
- (if port (setq imap-port port))
- (if auth (setq imap-auth auth))
- (if stream (setq imap-stream stream))
- (if (and imap-stream imap-auth)
(imap-open-1 buffer)
! ;; Determine network stream and/or auth mechanism to use
! (if (not (let ((imap-stream (or imap-stream imap-default-stream)))
! (imap-open-1 buffer)))
! ;; clean up and exit
! (when (memq buffer imap-buffer-list)
! (kill-buffer buffer)
! (setq imap-buffer-list (delq buffer imap-buffer-list)))
! ;; Choose stream.
! (when (null imap-stream)
! (let ((streams imap-streams))
! (while (setq stream (pop streams))
! (if (funcall (nth 1 (assq stream imap-stream-alist)) buffer)
! (setq stream-changed (not (eq (or imap-stream
! imap-default-stream)
! stream))
! imap-stream stream
! streams nil)))
! (unless imap-stream
! (error "Couldn't figure out a stream for server"))))
;; Choose authenticator
(when (null imap-auth)
(let ((auths imap-authenticators))
--- 530,568 ----
available authenticators. If nil, it choices the best stream the
server is capable of.
BUFFER can be a buffer or a name of a buffer, which is created if
! necessery. If nil, the buffer name is generated."
(setq buffer (or buffer (format " *imap* %s:%d" server (or port 0))))
(with-current-buffer (get-buffer-create buffer)
! (if (imap-opened buffer)
! (imap-close buffer))
! (mapc 'make-variable-buffer-local imap-local-variables)
! (imap-disable-multibyte)
! (buffer-disable-undo)
! (setq imap-server (or server imap-server))
! (setq imap-port (or port imap-port))
! (setq imap-auth (or auth imap-auth))
! (setq imap-stream (or stream imap-stream))
! (when (let ((imap-stream (or imap-stream imap-default-stream)))
! (imap-open-1 buffer))
! ;; Choose stream.
! (let (stream-changed)
! (when (null imap-stream)
! (let ((streams imap-streams))
! (while (setq stream (pop streams))
! (if (funcall (nth 1 (assq stream imap-stream-alist)) buffer)
! (setq stream-changed (not (eq (or imap-stream
! imap-default-stream)
! stream))
! imap-stream stream
! streams nil)))
! (unless imap-stream
! (error "Couldn't figure out a stream for server"))))
! (when stream-changed
! (message "Reconnecting with %s..." imap-stream)
(imap-close buffer)
(imap-open-1 buffer)
! (setq imap-capability nil)))
! (if (imap-opened buffer)
;; Choose authenticator
(when (null imap-auth)
(let ((auths imap-authenticators))
***************
*** 561,571 ****
(setq imap-auth auth
auths nil)))
(unless imap-auth
! (error "Couldn't figure out authenticator for server"))))
! (when stream-changed
! (message "Reconnecting with %s..." imap-stream)
! (imap-close buffer)
! (imap-open-1 buffer))))))
(if (imap-opened buffer)
buffer))
--- 572,578 ----
(setq imap-auth auth
auths nil)))
(unless imap-auth
! (error "Couldn't figure out authenticator for server")))))))
(if (imap-opened buffer)
buffer))
***************
*** 578,591 ****
(and imap-process
(memq (process-status imap-process) '(open run))))))
! (defun imap-authenticate (buffer &optional user passwd)
"Authenticate to server in BUFFER, using current buffer if nil. It
uses the authenticator specified when opening the server. If the
authenticator requires username/passwords, they are queried from the
user and optionally stored in the buffer. If USER and/or PASSWD is
specified, the user will not be questioned and the username and/or
password is remembered in the buffer."
! (with-current-buffer buffer
(when (eq imap-state 'nonauth)
(make-variable-buffer-local 'imap-username)
(make-variable-buffer-local 'imap-password)
--- 585,598 ----
(and imap-process
(memq (process-status imap-process) '(open run))))))
! (defun imap-authenticate (&optional buffer user passwd)
"Authenticate to server in BUFFER, using current buffer if nil. It
uses the authenticator specified when opening the server. If the
authenticator requires username/passwords, they are queried from the
user and optionally stored in the buffer. If USER and/or PASSWD is
specified, the user will not be questioned and the username and/or
password is remembered in the buffer."
! (with-current-buffer (or buffer (current-buffer))
(when (eq imap-state 'nonauth)
(make-variable-buffer-local 'imap-username)
(make-variable-buffer-local 'imap-password)
***************
*** 628,634 ****
(with-current-buffer (or buffer (current-buffer))
(unless imap-namespace
(when (imap-capability 'NAMESPACE)
! (imap-send-command-wait 'NAMESPACE)))
imap-namespace))
(defun imap-send-command-wait (command &optional buffer)
--- 635,641 ----
(with-current-buffer (or buffer (current-buffer))
(unless imap-namespace
(when (imap-capability 'NAMESPACE)
! (imap-send-command-wait "NAMESPACE")))
imap-namespace))
(defun imap-send-command-wait (command &optional buffer)
***************
*** 983,1005 ****
;; ; is considered to be INBOX and not an astring.
;; ; Refer to section 5.1 for further
;; ; semantic details of mailbox names.
- ;;
- ;; astring = atom / string
- ;;
- ;; atom = 1*ATOM-CHAR
- ;;
- ;; ATOM-CHAR = <any CHAR except atom-specials>
- ;;
- ;; atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards /
- ;; quoted-specials
- ;;
- ;; list-wildcards = "%" / "*"
- ;;
- ;; quoted-specials = DQUOTE / "\"
(defsubst imap-parse-mailbox ()
! (let ((mailbox (or (imap-parse-string)
! (format "%s" (read (current-buffer))))))
(if (string-equal "INBOX" (upcase mailbox))
"INBOX"
mailbox)))
--- 990,1000 ----
;; ; is considered to be INBOX and not an astring.
;; ; Refer to section 5.1 for further
;; ; semantic details of mailbox names.
(defsubst imap-parse-mailbox ()
! (let ((mailbox (imap-parse-astring)))
! (and (symbolp mailbox)
! (setq mailbox (symbol-name mailbox)))
(if (string-equal "INBOX" (upcase mailbox))
"INBOX"
mailbox)))
***************
*** 1085,1091 ****
;; "BADCHARSET [SP "(" astring *(SP astring) ")" ] /
;; "NEWNAME" SP string SP string /
;; "PARSE" /
! ;; "PERMANENTFLAGS" SP "(" [flag-perm *(SP flag-perm)] ")" /
;; "READ-ONLY" /
;; "READ-WRITE" /
;; "TRYCREATE" /
--- 1080,1087 ----
;; "BADCHARSET [SP "(" astring *(SP astring) ")" ] /
;; "NEWNAME" SP string SP string /
;; "PARSE" /
! ;; "PERMANENTFLAGS" SP "("
! ;; [flag-perm *(SP flag-perm)] ")" /
;; "READ-ONLY" /
;; "READ-WRITE" /
;; "TRYCREATE" /
***************
*** 1115,1150 ****
;; resp-text-atom = 1*<any ATOM-CHAR except "]">
(defun imap-response-data-text-code (response)
! (assert (eq (char-after) ?\[))
! (forward-char)
! (cond ((search-forward "PERMANENTFLAGS " nil t)
! (imap-mailbox-put 'permanentflags (imap-parse-flag-list)))
! ((search-forward "UIDNEXT " nil t)
! (imap-mailbox-put 'uidnext (read (current-buffer))))
! ((search-forward "UNSEEN " nil t)
! (imap-mailbox-put 'unseen (read (current-buffer))))
! ((looking-at "UIDVALIDITY \\([0-9]+\\)")
! (imap-mailbox-put 'uidvalidity (match-string 1)))
! ((search-forward "READ-ONLY" nil t)
! (imap-mailbox-put 'read-only t))
! ((search-forward "COPYUID" nil t)
! t)
! ((search-forward "NEWNAME " nil t)
! (let (oldname newname)
! (setq oldname (imap-parse-string))
! (forward-char)
! (setq newname (imap-parse-string))
! (imap-mailbox-put 'newname newname oldname)))
! ((search-forward "TRYCREATE" nil t)
! (imap-mailbox-put 'trycreate t))
! ((looking-at "APPENDUID \\([0-9]+\\) \\([0-9]+\\)")
! (imap-mailbox-put 'appenduid
! (list (match-string 1)
! (string-to-number (match-string 2)))
! imap-current-target-mailbox))
! ((search-forward "ALERT] " nil t)
! (message "Imap server %s information: %s" imap-server
! (buffer-substring (point) (point-max))))))
;; response-data = "*" SP (resp-cond-state / resp-cond-bye /
;; mailbox-data / message-data / capability-data) CRLF
--- 1111,1146 ----
;; resp-text-atom = 1*<any ATOM-CHAR except "]">
(defun imap-response-data-text-code (response)
! (when (eq (char-after) ?\[)
! (forward-char)
! (cond ((search-forward "PERMANENTFLAGS " nil t)
! (imap-mailbox-put 'permanentflags (imap-parse-flag-list)))
! ((search-forward "UIDNEXT " nil t)
! (imap-mailbox-put 'uidnext (read (current-buffer))))
! ((search-forward "UNSEEN " nil t)
! (imap-mailbox-put 'unseen (read (current-buffer))))
! ((looking-at "UIDVALIDITY \\([0-9]+\\)")
! (imap-mailbox-put 'uidvalidity (match-string 1)))
! ((search-forward "READ-ONLY" nil t)
! (imap-mailbox-put 'read-only t))
! ((search-forward "COPYUID" nil t)
! t)
! ((search-forward "NEWNAME " nil t)
! (let (oldname newname)
! (setq oldname (imap-parse-string))
! (forward-char)
! (setq newname (imap-parse-string))
! (imap-mailbox-put 'newname newname oldname)))
! ((search-forward "TRYCREATE" nil t)
! (imap-mailbox-put 'trycreate t))
! ((looking-at "APPENDUID \\([0-9]+\\) \\([0-9]+\\)")
! (imap-mailbox-put 'appenduid
! (list (match-string 1)
! (string-to-number (match-string 2)))
! imap-current-target-mailbox))
! ((search-forward "ALERT] " nil t)
! (message "Imap server %s information: %s" imap-server
! (buffer-substring (point) (point-max)))))))
;; response-data = "*" SP (resp-cond-state / resp-cond-bye /
;; mailbox-data / message-data / capability-data) CRLF
***************
*** 1282,1326 ****
;; ; Strictly ascending
(defun imap-response-data-fetch (response)
! (if (not (save-excursion (re-search-forward "UID \\([0-9]+\\)" nil t)))
! (message "Skipping UID-less fetch response (probably broken server)...")
! (setq imap-current-message (string-to-number (match-string 1)))
! (imap-message-put imap-current-message 'UID imap-current-message)
(assert (eq (char-after) ?\())
(while (not (eq (char-after) ?\)))
(forward-char)
(let ((token (read (current-buffer))))
(forward-char)
(cond ((eq token 'UID)
! (forward-sexp))
((eq token 'FLAGS)
! (imap-message-put imap-current-message 'FLAGS
! (imap-parse-flag-list)))
((eq token 'ENVELOPE)
! (imap-message-put imap-current-message 'ENVELOPE
! (imap-parse-envelope)))
((eq token 'INTERNALDATE)
! (imap-message-put imap-current-message 'INTERNALDATE
! (read (current-buffer))))
((eq token 'RFC822)
! (imap-message-put imap-current-message 'RFC822
! (imap-parse-nstring)))
((eq token 'RFC822.HEADER)
! (imap-message-put imap-current-message 'RFC822.HEADER
! (imap-parse-nstring)))
((eq token 'RFC822.TEXT)
! (imap-message-put imap-current-message 'RFC822.TEXT
! (imap-parse-nstring)))
((eq token 'RFC822.SIZE)
! (imap-message-put imap-current-message 'RFC822.SIZE
! (read (current-buffer))))
((eq token 'BODY)
! (imap-message-put imap-current-message 'BODY
! (imap-parse-body)))
((eq token 'BODYSTRUCTURE)
! (imap-message-put imap-current-message 'BODYSTRUCTURE
! (imap-parse-body))))))
! (run-hooks 'imap-fetch-data-hook)))
;; mailbox-data = ...
;; "SEARCH" *(SP nz-number) /
--- 1278,1324 ----
;; ; Strictly ascending
(defun imap-response-data-fetch (response)
! (let (uid flags envelope internaldate rfc822 rfc822header rfc822text
! rfc822size body bodystructure)
(assert (eq (char-after) ?\())
(while (not (eq (char-after) ?\)))
(forward-char)
(let ((token (read (current-buffer))))
(forward-char)
(cond ((eq token 'UID)
! (setq uid (read (current-buffer))))
((eq token 'FLAGS)
! (setq flags (imap-parse-flag-list)))
((eq token 'ENVELOPE)
! (setq envelope (imap-parse-envelope)))
((eq token 'INTERNALDATE)
! (setq internaldate (imap-parse-string)))
((eq token 'RFC822)
! (setq rfc822 (imap-parse-nstring)))
((eq token 'RFC822.HEADER)
! (setq rfc822header (imap-parse-nstring)))
((eq token 'RFC822.TEXT)
! (setq rfc822text (imap-parse-nstring)))
((eq token 'RFC822.SIZE)
! (setq rfc822size (read (current-buffer))))
((eq token 'BODY)
! (setq body (imap-parse-body)))
((eq token 'BODYSTRUCTURE)
! (setq bodystructure (imap-parse-body))))))
! (if (not uid)
! (message "Skipping UID-less fetch response (broken server?)...")
! (setq imap-current-message uid)
! (imap-message-put uid 'UID uid)
! (and flags (imap-message-put uid 'FLAGS flags))
! (and envelope (imap-message-put uid 'ENVELOPE envelope))
! (and internaldate (imap-message-put uid 'INTERNALDATE internaldate))
! (and rfc822 (imap-message-put uid 'RFC822 rfc822))
! (and rfc822header (imap-message-put uid 'RFC822.HEADER rfc822header))
! (and rfc822text (imap-message-put uid 'RFC822.TEXT rfc822text))
! (and rfc822size (imap-message-put uid 'RFC822.SIZE rfc822size))
! (and body (imap-message-put uid 'BODY body))
! (and bodystructure (imap-message-put uid 'BODYSTRUCTURE bodystructure))
! (run-hooks 'imap-fetch-data-hook))))
;; mailbox-data = ...
;; "SEARCH" *(SP nz-number) /
Index: nnimap/nnimap.el
diff -c nnimap/nnimap.el:1.119 nnimap/nnimap.el:1.122
*** nnimap/nnimap.el:1.119 Sat Dec 26 13:06:37 1998
--- nnimap/nnimap.el Mon Jan 4 13:50:28 1999
***************
*** 96,102 ****
(nnoo-declare nnimap) ; we derive from no one
! (defconst nnimap-version "nnimap 0.89")
;; Various server variables.
--- 96,102 ----
(nnoo-declare nnimap) ; we derive from no one
! (defconst nnimap-version "nnimap 0.90")
;; Various server variables.
***************
*** 587,593 ****
;;; Returns: GROUP HIGHEST LOWEST [ynmxj=]
(defun nnimap-request-list-mapper (group)
! (unless (or (member "\\NoSelect" (imap-mailbox-get 'flags group))
;; We ignore groups with spaces (Gnus can't handle them)
(string-match " " group))
(let (high)
--- 587,593 ----
;;; Returns: GROUP HIGHEST LOWEST [ynmxj=]
(defun nnimap-request-list-mapper (group)
! (unless (or (member "\\NoSelect" (imap-mailbox-get 'list-flags group))
;; We ignore groups with spaces (Gnus can't handle them)
(string-match " " group))
(let (high)
***************
*** 718,724 ****
(mapc (lambda (pred)
(when (and (nnimap-mark-permanent-p (cdr pred))
(member (nnimap-mark-to-flag (cdr pred))
! (imap-mailbox-get 'list-flags)))
(gnus-info-set-marks
info
(nnimap-update-alist-soft
--- 718,724 ----
(mapc (lambda (pred)
(when (and (nnimap-mark-permanent-p (cdr pred))
(member (nnimap-mark-to-flag (cdr pred))
! (imap-mailbox-get 'flags)))
(gnus-info-set-marks
info
(nnimap-update-alist-soft