[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r102739: nnimap.el (nnimap-login): Re
From: |
Katsumi Yamaoka |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r102739: nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5. |
Date: |
Sun, 02 Jan 2011 23:17:32 +0000 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 102739
author: Lars Magne Ingebrigtsen <address@hidden>
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Sun 2011-01-02 23:17:32 +0000
message:
nnimap.el (nnimap-login): Refactored out into own function, and implement
CRAM-MD5.
(nnimap-wait-for-line): Refactored out.
shr.el (shr-rescale-image): Display all GIF images as animated images.
nnimap.el (nnimap-login): Prefer AUTH=CRAM-MD5, if it's available. This
avoids sending passwords in plain text over non-encrypted channels.
modified:
lisp/gnus/ChangeLog
lisp/gnus/nnimap.el
lisp/gnus/shr.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog 2011-01-02 11:23:02 +0000
+++ b/lisp/gnus/ChangeLog 2011-01-02 23:17:32 +0000
@@ -1,5 +1,15 @@
2011-01-02 Lars Magne Ingebrigtsen <address@hidden>
+ * nnimap.el (nnimap-login): Prefer AUTH=CRAM-MD5, if it's available.
+ This avoids sending passwords in plain text over non-encrypted
+ channels.
+
+ * shr.el (shr-rescale-image): Display all GIF images as animated images.
+
+ * nnimap.el (nnimap-login): Refactored out into own function, and
+ implement CRAM-MD5.
+ (nnimap-wait-for-line): Refactored out.
+
* mm-view.el (mml-smime): Require.
2010-12-20 David Engster <address@hidden>
=== modified file 'lisp/gnus/nnimap.el'
--- a/lisp/gnus/nnimap.el 2011-01-02 11:23:02 +0000
+++ b/lisp/gnus/nnimap.el 2011-01-02 23:17:32 +0000
@@ -390,17 +390,7 @@
(nnimap-credentials nnimap-address ports)))))
(setq nnimap-object nil)
(setq login-result
- (if (and (nnimap-capability "AUTH=PLAIN")
- (nnimap-capability "LOGINDISABLED"))
- (nnimap-command
- "AUTHENTICATE PLAIN %s"
- (base64-encode-string
- (format "\000%s\000%s"
- (nnimap-quote-specials (car credentials))
- (nnimap-quote-specials (cadr
credentials)))))
- (nnimap-command "LOGIN %S %S"
- (car credentials)
- (cadr credentials))))
+ (nnimap-login (car credentials) (cadr credentials)))
(unless (car login-result)
;; If the login failed, then forget the credentials
;; that are now possibly cached.
@@ -417,6 +407,33 @@
(nnimap-command "ENABLE QRESYNC"))
(nnimap-process nnimap-object))))))))
+(autoload 'rfc2104-hash "rfc2104")
+
+(defun nnimap-login (user password)
+ (cond
+ ((nnimap-capability "AUTH=CRAM-MD5")
+ (erase-buffer)
+ (let ((sequence (nnimap-send-command "AUTHENTICATE CRAM-MD5"))
+ (challenge (nnimap-wait-for-line "^\\+\\(.*\\)\n")))
+ (process-send-string
+ (get-buffer-process (current-buffer))
+ (concat
+ (base64-encode-string
+ (concat user " "
+ (rfc2104-hash 'md5 64 16 password
+ (base64-decode-string challenge))))
+ "\r\n"))
+ (nnimap-wait-for-response sequence)))
+ ((not (nnimap-capability "LOGINDISABLED"))
+ (nnimap-command "LOGIN %S %S" user password))
+ ((nnimap-capability "AUTH=PLAIN")
+ (nnimap-command
+ "AUTHENTICATE PLAIN %s"
+ (base64-encode-string
+ (format "\000%s\000%s"
+ (nnimap-quote-specials user)
+ (nnimap-quote-specials password)))))))
+
(defun nnimap-quote-specials (string)
(with-temp-buffer
(insert string)
@@ -1541,8 +1558,9 @@
(nnimap-parse-response))
(defun nnimap-wait-for-connection (&optional regexp)
- (unless regexp
- (setq regexp "^[*.] .*\n"))
+ (nnimap-wait-for-line (or regexp "^[*.] .*\n") "[*.] \\([A-Z0-9]+\\)"))
+
+(defun nnimap-wait-for-line (regexp &optional response-regexp)
(let ((process (get-buffer-process (current-buffer))))
(goto-char (point-min))
(while (and (memq (process-status process)
@@ -1551,7 +1569,7 @@
(nnheader-accept-process-output process)
(goto-char (point-min)))
(forward-line -1)
- (and (looking-at "[*.] \\([A-Z0-9]+\\)")
+ (and (looking-at (or response-regexp regexp))
(match-string 1))))
(defun nnimap-wait-for-response (sequence &optional messagep)
=== modified file 'lisp/gnus/shr.el'
--- a/lisp/gnus/shr.el 2011-01-02 11:23:02 +0000
+++ b/lisp/gnus/shr.el 2011-01-02 23:17:32 +0000
@@ -507,6 +507,9 @@
(create-image data 'imagemagick t
:width window-width)
image)))
+ (when (and (fboundp 'create-animated-image)
+ (eq (image-type data nil t) 'gif))
+ (setq image (create-animated-image data 'gif t)))
image)))
;; url-cache-extract autoloads url-cache.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r102739: nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.,
Katsumi Yamaoka <=