diff options
| author | Katsumi Yamaoka | 2010-11-11 23:51:05 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2010-11-11 23:51:05 +0000 |
| commit | b0feab7d2c1159c8d8937c846e9e0552ad63684a (patch) | |
| tree | 21b8b51951f7f9ed761cf4115241551e6984fd4d | |
| parent | ec54e7a421075e0b973d72dbf0ab099a328dbe8a (diff) | |
| download | emacs-b0feab7d2c1159c8d8937c846e9e0552ad63684a.tar.gz emacs-b0feab7d2c1159c8d8937c846e9e0552ad63684a.zip | |
Make mm-dissect-buffer pass sender's mail address to smime-decrypt-region.
mm-decode.el (mm-dissect-buffer): Pass sender's mail address to smime-decrypt-region using function argument.
mm-decode.el (mm-possibly-verify-or-decrypt, mm-dissect-multipart): Relay it.
mm-view.el (mm-view-pkcs7, mm-view-pkcs7-decrypt): Relay it.
smime.el (smime-decrypt-region): Catch it.
| -rw-r--r-- | lisp/gnus/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/gnus/mm-decode.el | 8 | ||||
| -rw-r--r-- | lisp/gnus/mm-view.el | 9 | ||||
| -rw-r--r-- | lisp/gnus/smime.el | 9 |
4 files changed, 21 insertions, 15 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 0365b34e8ee..64752711f98 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2010-11-11 Katsumi Yamaoka <yamaoka@jpl.org> | ||
| 2 | |||
| 3 | * mm-decode.el (mm-dissect-buffer): Pass sender's mail address to | ||
| 4 | smime-decrypt-region using function argument. | ||
| 5 | (mm-possibly-verify-or-decrypt, mm-dissect-multipart): Relay it. | ||
| 6 | |||
| 7 | * mm-view.el (mm-view-pkcs7, mm-view-pkcs7-decrypt): Relay it. | ||
| 8 | |||
| 9 | * smime.el (smime-decrypt-region): Catch it. | ||
| 10 | |||
| 1 | 2010-11-11 Stefan Monnier <monnier@iro.umontreal.ca> | 11 | 2010-11-11 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 12 | ||
| 3 | * smime.el (smime-mode-map): Move initialization into declaration. | 13 | * smime.el (smime-mode-map): Move initialization into declaration. |
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el index bcd6a80f1e8..2ab5a548e42 100644 --- a/lisp/gnus/mm-decode.el +++ b/lisp/gnus/mm-decode.el | |||
| @@ -624,7 +624,7 @@ Postpone undisplaying of viewers for types in | |||
| 624 | no-strict-mime | 624 | no-strict-mime |
| 625 | (and cd (mail-header-parse-content-disposition cd)) | 625 | (and cd (mail-header-parse-content-disposition cd)) |
| 626 | description id) | 626 | description id) |
| 627 | ctl)))) | 627 | ctl from)))) |
| 628 | (when id | 628 | (when id |
| 629 | (when (string-match " *<\\(.*\\)> *" id) | 629 | (when (string-match " *<\\(.*\\)> *" id) |
| 630 | (setq id (match-string 1 id))) | 630 | (setq id (match-string 1 id))) |
| @@ -666,7 +666,7 @@ Postpone undisplaying of viewers for types in | |||
| 666 | (save-restriction | 666 | (save-restriction |
| 667 | (narrow-to-region start end) | 667 | (narrow-to-region start end) |
| 668 | (setq parts (nconc (list (mm-dissect-buffer t nil from)) parts))))) | 668 | (setq parts (nconc (list (mm-dissect-buffer t nil from)) parts))))) |
| 669 | (mm-possibly-verify-or-decrypt (nreverse parts) ctl))) | 669 | (mm-possibly-verify-or-decrypt (nreverse parts) ctl from))) |
| 670 | 670 | ||
| 671 | (defun mm-copy-to-buffer () | 671 | (defun mm-copy-to-buffer () |
| 672 | "Copy the contents of the current buffer to a fresh buffer." | 672 | "Copy the contents of the current buffer to a fresh buffer." |
| @@ -1569,7 +1569,7 @@ If RECURSIVE, search recursively." | |||
| 1569 | 1569 | ||
| 1570 | (autoload 'mm-view-pkcs7 "mm-view") | 1570 | (autoload 'mm-view-pkcs7 "mm-view") |
| 1571 | 1571 | ||
| 1572 | (defun mm-possibly-verify-or-decrypt (parts ctl) | 1572 | (defun mm-possibly-verify-or-decrypt (parts ctl &optional from) |
| 1573 | (let ((type (car ctl)) | 1573 | (let ((type (car ctl)) |
| 1574 | (subtype (cadr (split-string (car ctl) "/"))) | 1574 | (subtype (cadr (split-string (car ctl) "/"))) |
| 1575 | (mm-security-handle ctl) ;; (car CTL) is the type. | 1575 | (mm-security-handle ctl) ;; (car CTL) is the type. |
| @@ -1584,7 +1584,7 @@ If RECURSIVE, search recursively." | |||
| 1584 | ((eq mm-decrypt-option 'known) t) | 1584 | ((eq mm-decrypt-option 'known) t) |
| 1585 | (t (y-or-n-p | 1585 | (t (y-or-n-p |
| 1586 | (format "Decrypt (S/MIME) part? ")))) | 1586 | (format "Decrypt (S/MIME) part? ")))) |
| 1587 | (mm-view-pkcs7 parts)) | 1587 | (mm-view-pkcs7 parts from)) |
| 1588 | (setq parts (mm-dissect-buffer t))))) | 1588 | (setq parts (mm-dissect-buffer t))))) |
| 1589 | ((equal subtype "signed") | 1589 | ((equal subtype "signed") |
| 1590 | (unless (and (setq protocol | 1590 | (unless (and (setq protocol |
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index f6214759813..083781b0f9d 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el | |||
| @@ -653,9 +653,9 @@ | |||
| 653 | (t | 653 | (t |
| 654 | (error "Could not identify PKCS#7 type"))))) | 654 | (error "Could not identify PKCS#7 type"))))) |
| 655 | 655 | ||
| 656 | (defun mm-view-pkcs7 (handle) | 656 | (defun mm-view-pkcs7 (handle &optional from) |
| 657 | (case (mm-view-pkcs7-get-type handle) | 657 | (case (mm-view-pkcs7-get-type handle) |
| 658 | (enveloped (mm-view-pkcs7-decrypt handle)) | 658 | (enveloped (mm-view-pkcs7-decrypt handle from)) |
| 659 | (signed (mm-view-pkcs7-verify handle)) | 659 | (signed (mm-view-pkcs7-verify handle)) |
| 660 | (otherwise (error "Unknown or unimplemented PKCS#7 type")))) | 660 | (otherwise (error "Unknown or unimplemented PKCS#7 type")))) |
| 661 | 661 | ||
| @@ -680,7 +680,7 @@ | |||
| 680 | (replace-match "\n")) | 680 | (replace-match "\n")) |
| 681 | t) | 681 | t) |
| 682 | 682 | ||
| 683 | (defun mm-view-pkcs7-decrypt (handle) | 683 | (defun mm-view-pkcs7-decrypt (handle &optional from) |
| 684 | (insert-buffer-substring (mm-handle-buffer handle)) | 684 | (insert-buffer-substring (mm-handle-buffer handle)) |
| 685 | (goto-char (point-min)) | 685 | (goto-char (point-min)) |
| 686 | (insert "MIME-Version: 1.0\n") | 686 | (insert "MIME-Version: 1.0\n") |
| @@ -692,7 +692,8 @@ | |||
| 692 | (smime-get-key-by-email | 692 | (smime-get-key-by-email |
| 693 | (gnus-completing-read | 693 | (gnus-completing-read |
| 694 | "Decipher using key" | 694 | "Decipher using key" |
| 695 | smime-keys nil nil nil (car-safe (car-safe smime-keys)))))) | 695 | smime-keys nil nil nil (car-safe (car-safe smime-keys))))) |
| 696 | from) | ||
| 696 | (goto-char (point-min)) | 697 | (goto-char (point-min)) |
| 697 | (while (search-forward "\r\n" nil t) | 698 | (while (search-forward "\r\n" nil t) |
| 698 | (replace-match "\n")) | 699 | (replace-match "\n")) |
diff --git a/lisp/gnus/smime.el b/lisp/gnus/smime.el index 5363a40c727..0695d5ac82e 100644 --- a/lisp/gnus/smime.el +++ b/lisp/gnus/smime.el | |||
| @@ -426,11 +426,7 @@ Any details (stdout and stderr) are left in the buffer specified by | |||
| 426 | (insert-buffer-substring smime-details-buffer) | 426 | (insert-buffer-substring smime-details-buffer) |
| 427 | nil)) | 427 | nil)) |
| 428 | 428 | ||
| 429 | ;; TODO: fix this properly by giving it a prefix. | 429 | (defun smime-decrypt-region (b e keyfile &optional from) |
| 430 | (if (featurep 'xemacs) | ||
| 431 | (defvar from)) | ||
| 432 | |||
| 433 | (defun smime-decrypt-region (b e keyfile) | ||
| 434 | "Decrypt S/MIME message in region between B and E with key in KEYFILE. | 430 | "Decrypt S/MIME message in region between B and E with key in KEYFILE. |
| 435 | On success, replaces region with decrypted data and return non-nil. | 431 | On success, replaces region with decrypted data and return non-nil. |
| 436 | Any details (stderr on success, stdout and stderr on error) are left | 432 | Any details (stderr on success, stdout and stderr on error) are left |
| @@ -454,8 +450,7 @@ in the buffer specified by `smime-details-buffer'." | |||
| 454 | (delete-file tmpfile))) | 450 | (delete-file tmpfile))) |
| 455 | (progn | 451 | (progn |
| 456 | (delete-region b e) | 452 | (delete-region b e) |
| 457 | (when (boundp 'from) | 453 | (when from |
| 458 | ;; `from' is dynamically bound in mm-dissect. | ||
| 459 | (insert "From: " from "\n")) | 454 | (insert "From: " from "\n")) |
| 460 | (insert-buffer-substring buffer) | 455 | (insert-buffer-substring buffer) |
| 461 | (kill-buffer buffer) | 456 | (kill-buffer buffer) |