aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2011-01-02 23:17:32 +0000
committerKatsumi Yamaoka2011-01-02 23:17:32 +0000
commit84d89edee634f27b7d635393f762bd520f9f4b78 (patch)
treeff9aba84c2f368c204c2aab386827943b5628f94
parent3d4cad2cc94097362389a8ff35c404a87bd38581 (diff)
downloademacs-84d89edee634f27b7d635393f762bd520f9f4b78.tar.gz
emacs-84d89edee634f27b7d635393f762bd520f9f4b78.zip
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.
-rw-r--r--lisp/gnus/ChangeLog10
-rw-r--r--lisp/gnus/nnimap.el46
-rw-r--r--lisp/gnus/shr.el3
3 files changed, 45 insertions, 14 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 465ff2b3cab..00702e73596 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,5 +1,15 @@
12011-01-02 Lars Magne Ingebrigtsen <larsi@gnus.org> 12011-01-02 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 2
3 * nnimap.el (nnimap-login): Prefer AUTH=CRAM-MD5, if it's available.
4 This avoids sending passwords in plain text over non-encrypted
5 channels.
6
7 * shr.el (shr-rescale-image): Display all GIF images as animated images.
8
9 * nnimap.el (nnimap-login): Refactored out into own function, and
10 implement CRAM-MD5.
11 (nnimap-wait-for-line): Refactored out.
12
3 * mm-view.el (mml-smime): Require. 13 * mm-view.el (mml-smime): Require.
4 14
52010-12-20 David Engster <deng@eml.cc> 152010-12-20 David Engster <deng@eml.cc>
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 1899b0ef030..51fa532a371 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -390,17 +390,7 @@ textual parts.")
390 (nnimap-credentials nnimap-address ports))))) 390 (nnimap-credentials nnimap-address ports)))))
391 (setq nnimap-object nil) 391 (setq nnimap-object nil)
392 (setq login-result 392 (setq login-result
393 (if (and (nnimap-capability "AUTH=PLAIN") 393 (nnimap-login (car credentials) (cadr credentials)))
394 (nnimap-capability "LOGINDISABLED"))
395 (nnimap-command
396 "AUTHENTICATE PLAIN %s"
397 (base64-encode-string
398 (format "\000%s\000%s"
399 (nnimap-quote-specials (car credentials))
400 (nnimap-quote-specials (cadr credentials)))))
401 (nnimap-command "LOGIN %S %S"
402 (car credentials)
403 (cadr credentials))))
404 (unless (car login-result) 394 (unless (car login-result)
405 ;; If the login failed, then forget the credentials 395 ;; If the login failed, then forget the credentials
406 ;; that are now possibly cached. 396 ;; that are now possibly cached.
@@ -417,6 +407,33 @@ textual parts.")
417 (nnimap-command "ENABLE QRESYNC")) 407 (nnimap-command "ENABLE QRESYNC"))
418 (nnimap-process nnimap-object)))))))) 408 (nnimap-process nnimap-object))))))))
419 409
410(autoload 'rfc2104-hash "rfc2104")
411
412(defun nnimap-login (user password)
413 (cond
414 ((nnimap-capability "AUTH=CRAM-MD5")
415 (erase-buffer)
416 (let ((sequence (nnimap-send-command "AUTHENTICATE CRAM-MD5"))
417 (challenge (nnimap-wait-for-line "^\\+\\(.*\\)\n")))
418 (process-send-string
419 (get-buffer-process (current-buffer))
420 (concat
421 (base64-encode-string
422 (concat user " "
423 (rfc2104-hash 'md5 64 16 password
424 (base64-decode-string challenge))))
425 "\r\n"))
426 (nnimap-wait-for-response sequence)))
427 ((not (nnimap-capability "LOGINDISABLED"))
428 (nnimap-command "LOGIN %S %S" user password))
429 ((nnimap-capability "AUTH=PLAIN")
430 (nnimap-command
431 "AUTHENTICATE PLAIN %s"
432 (base64-encode-string
433 (format "\000%s\000%s"
434 (nnimap-quote-specials user)
435 (nnimap-quote-specials password)))))))
436
420(defun nnimap-quote-specials (string) 437(defun nnimap-quote-specials (string)
421 (with-temp-buffer 438 (with-temp-buffer
422 (insert string) 439 (insert string)
@@ -1541,8 +1558,9 @@ textual parts.")
1541 (nnimap-parse-response)) 1558 (nnimap-parse-response))
1542 1559
1543(defun nnimap-wait-for-connection (&optional regexp) 1560(defun nnimap-wait-for-connection (&optional regexp)
1544 (unless regexp 1561 (nnimap-wait-for-line (or regexp "^[*.] .*\n") "[*.] \\([A-Z0-9]+\\)"))
1545 (setq regexp "^[*.] .*\n")) 1562
1563(defun nnimap-wait-for-line (regexp &optional response-regexp)
1546 (let ((process (get-buffer-process (current-buffer)))) 1564 (let ((process (get-buffer-process (current-buffer))))
1547 (goto-char (point-min)) 1565 (goto-char (point-min))
1548 (while (and (memq (process-status process) 1566 (while (and (memq (process-status process)
@@ -1551,7 +1569,7 @@ textual parts.")
1551 (nnheader-accept-process-output process) 1569 (nnheader-accept-process-output process)
1552 (goto-char (point-min))) 1570 (goto-char (point-min)))
1553 (forward-line -1) 1571 (forward-line -1)
1554 (and (looking-at "[*.] \\([A-Z0-9]+\\)") 1572 (and (looking-at (or response-regexp regexp))
1555 (match-string 1)))) 1573 (match-string 1))))
1556 1574
1557(defun nnimap-wait-for-response (sequence &optional messagep) 1575(defun nnimap-wait-for-response (sequence &optional messagep)
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index 0ed73cd226b..6e681d67365 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -507,6 +507,9 @@ redirects somewhere else."
507 (create-image data 'imagemagick t 507 (create-image data 'imagemagick t
508 :width window-width) 508 :width window-width)
509 image))) 509 image)))
510 (when (and (fboundp 'create-animated-image)
511 (eq (image-type data nil t) 'gif))
512 (setq image (create-animated-image data 'gif t)))
510 image))) 513 image)))
511 514
512;; url-cache-extract autoloads url-cache. 515;; url-cache-extract autoloads url-cache.