emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 84ef1ea: Make it possible to view S/MIME verified e


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 84ef1ea: Make it possible to view S/MIME verified emails
Date: Thu, 26 Sep 2019 10:24:39 -0400 (EDT)

branch: master
commit 84ef1ea8b524f8998fc8674b99cf8069e38dce4f
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Make it possible to view S/MIME verified emails
    
    * lisp/gnus/mm-decode.el (mm-possibly-verify-or-decrypt): When
    dissecting the result, we need a header (bug#18393).
    
    * lisp/gnus/mm-view.el (mm-view-pkcs7-verify): Insert the verified
    string.
    
    * lisp/gnus/smime.el (smime-verify-region): Return the verified
    string.
---
 lisp/gnus/mm-decode.el |  3 +++
 lisp/gnus/mm-view.el   | 13 ++-----------
 lisp/gnus/smime.el     | 17 +++++++++++------
 3 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 673098b..42bf5f8 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -1672,6 +1672,8 @@ If RECURSIVE, search recursively."
                    (t (y-or-n-p
                        (format "Decrypt (S/MIME) part? "))))
                   (mm-view-pkcs7 parts from))
+         (goto-char (point-min))
+         (insert "Content-type: text/plain\n\n")
          (setq parts (mm-dissect-buffer t)))))
      ((equal subtype "signed")
       (unless (and (setq protocol
@@ -1739,6 +1741,7 @@ If RECURSIVE, search recursively."
            (mm-set-handle-multipart-parameter
             mm-security-handle 'gnus-details
             (format "Unknown encrypt protocol (%s)" protocol)))))))
+    ;; Check the results (which are now in `parts').
     (let ((info (get-text-property 0 'gnus-info (car mm-security-handle))))
       (if (or (not info)
              (equal info "")
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index 02d9920..b66d152 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -588,18 +588,9 @@ If MODE is not set, try to find mode automatically."
       (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m")
       (insert-buffer-substring (mm-handle-buffer handle))
       (setq verified (smime-verify-region (point-min) (point-max))))
-    (goto-char (point-min))
-    (mm-insert-part handle)
-    (if (search-forward "Content-Type: " nil t)
-       (delete-region (point-min) (match-beginning 0)))
-    (goto-char (point-max))
-    (if (re-search-backward "--\r?\n?" nil t)
-       (delete-region (match-end 0) (point-max)))
-    (unless verified
+    (if verified
+       (insert verified)
       (insert-buffer-substring smime-details-buffer)))
-  (goto-char (point-min))
-  (while (search-forward "\r\n" nil t)
-    (replace-match "\n"))
   t)
 
 (autoload 'epg-decrypt-string "epg")
diff --git a/lisp/gnus/smime.el b/lisp/gnus/smime.el
index b7ec033..d8131c6 100644
--- a/lisp/gnus/smime.el
+++ b/lisp/gnus/smime.el
@@ -371,16 +371,21 @@ Any details (stdout and stderr) are left in the buffer 
specified by
                               (expand-file-name smime-CA-file)))
                     (if smime-CA-directory
                         (list "-CApath"
-                              (expand-file-name smime-CA-directory))))))
+                              (expand-file-name smime-CA-directory)))))
+       (input-buffer (current-buffer)))
     (unless CAs
       (error "No CA configured"))
     (if smime-crl-check
        (cl-pushnew smime-crl-check CAs :test #'equal))
-    (if (apply 'smime-call-openssl-region b e (list smime-details-buffer t)
-              "smime" "-verify" "-out" "/dev/null" CAs)
-       t
-      (insert-buffer-substring smime-details-buffer)
-      nil)))
+    (with-temp-buffer
+      (let ((result-buffer (current-buffer)))
+       (with-current-buffer input-buffer
+         (if (apply 'smime-call-openssl-region b e (list result-buffer
+                                                         smime-details-buffer)
+                    "smime" "-verify" "-out" "-" CAs)
+             (with-current-buffer result-buffer
+               (buffer-string))
+           nil))))))
 
 (defun smime-noverify-region (b e)
   "Verify integrity of S/MIME message in region between B and E.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]