lisp/ChangeLog addition:
[gnus] / lisp / mml.el
index 285d053..c86a820 100644 (file)
@@ -151,7 +151,10 @@ one charsets.")
        (let* (secure-mode
               (taginfo (mml-read-tag))
               (recipients (cdr (assq 'recipients taginfo)))
-              (location (cdr (assq 'tag-location taginfo))))
+              (location (cdr (assq 'tag-location taginfo)))
+              (mode (cdr (assq 'mode taginfo)))
+              (method (cdr (assq 'method taginfo)))
+              tags)
          (save-excursion
            (if
                (re-search-forward
@@ -162,11 +165,16 @@ one charsets.")
            (goto-char location)
            (re-search-forward "<#secure[^\n]*>\n"))
          (delete-region (match-beginning 0) (match-end 0))
-         (mml-insert-tag secure-mode
-                         (cdr (assq 'mode taginfo))
-                         (cdr (assq 'method taginfo))
-                         (and recipients 'recipients)
-                         recipients)
+         (cond ((string= mode "sign")
+                (setq tags (list "sign" method)))
+               ((string= mode "encrypt")
+                (setq tags (list "encrypt" method)))
+               ((string= mode "signencrypt")
+                (setq tags (list "sign" method "encrypt" method))))
+         (eval `(mml-insert-tag ,secure-mode
+                                ,@tags
+                                ,(if recipients 'recipients)
+                                ,recipients))
          ;; restart the parse
          (goto-char location)))
        ((looking-at "<#multipart")
@@ -522,22 +530,29 @@ If MML is non-nil, return the buffer up till the correspondent mml tag."
              (insert "\n--" mml-boundary "--\n")))))
        (t
        (error "Invalid element: %S" cont)))
-      (let ((item (assoc (cdr (assq 'sign cont)) mml-sign-alist))
+      ;; handle sign & encrypt tags in a semi-smart way.
+      (let ((sign-item (assoc (cdr (assq 'sign cont)) mml-sign-alist))
+           (encrypt-item (assoc (cdr (assq 'encrypt cont))
+                                mml-encrypt-alist))
            sender recipients)
-       (when item
+       (when (or sign-item encrypt-item)
          (if (setq sender (cdr (assq 'sender cont)))
              (message-options-set 'message-sender sender))
          (if (setq recipients (cdr (assq 'recipients cont)))
              (message-options-set 'message-recipients recipients))
-         (funcall (nth 1 item) cont)))
-      (let ((item (assoc (cdr (assq 'encrypt cont)) mml-encrypt-alist))
-           sender recipients)
-       (when item
-         (if (setq sender (cdr (assq 'sender cont)))
-             (message-options-set 'message-sender sender))
-         (if (setq recipients (cdr (assq 'recipients cont)))
-             (message-options-set 'message-recipients recipients))
-         (funcall (nth 1 item) cont))))))
+         (let ((style (mml-signencrypt-style (first encrypt-item))))
+           ;; check if: we're both signing & encrypting, both methods
+           ;; are the same (why would they be different?!), and that
+           ;; the signencrypt style allows for combined operation.
+           (if (and sign-item encrypt-item (equal (first sign-item)
+                                                  (first encrypt-item))
+                    (equal style 'combined))
+               (funcall (nth 1 encrypt-item) cont t)
+             ;; otherwise, revert to the old behavior.
+             (when sign-item
+               (funcall (nth 1 sign-item) cont))
+             (when encrypt-item
+               (funcall (nth 1 encrypt-item) cont)))))))))
 
 (defun mml-compute-boundary (cont)
   "Return a unique boundary that does not exist in CONT."
@@ -1006,7 +1021,9 @@ If RAW, don't highlight the article."
        (let ((gnus-newsgroup-charset (car message-posting-charset))
              gnus-article-prepare-hook gnus-original-article-buffer)
          (run-hooks 'gnus-article-decode-hook)
-         (let ((gnus-newsgroup-name "dummy"))
+         (let ((gnus-newsgroup-name "dummy")
+               (gnus-newsrc-hashtb (or gnus-newsrc-hashtb
+                                       (gnus-make-hashtable 5))))
            (gnus-article-prepare-display))))
       ;; Disable article-mode-map.
       (use-local-map nil)