Gnus development mailing list
 help / color / mirror / Atom feed
From: Josh Huber <huber@alum.wpi.edu>
Subject: [PATCH] make sign/encrypt operate on the whole message
Date: Sat, 19 Jan 2002 02:38:50 -0500	[thread overview]
Message-ID: <87bsfqeqnp.fsf@paradoxical.net> (raw)

...regardless of parts.

What this does is insert a <!secure method=(pgp|pgpmime|smime
mode=(sign|encrypt)> at the top of a message buffer.

When the mml parsing code sees this "meta-meta" tag, it replaces it
with either a part or a multipart tag -- depending on whether or not
there are other parts specified in the document.

I'm sure there are bugs!  What do you think of the idea?  I think it's
good, but is there a better place to implement it?

I've only tested pgpmime, btw...with both signing and encrypting
messages with & without attachments.

my simple tests pass.

Comments?

gnus Patch (cvs -q diff -u):

Index: lisp/mml-sec.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mml-sec.el,v
retrieving revision 1.8
diff -u -r1.8 mml-sec.el
--- lisp/mml-sec.el	2001/11/12 21:33:12	1.8
+++ lisp/mml-sec.el	2002/01/19 07:39:34
@@ -127,6 +127,61 @@
   (interactive)
   (mml-secure-part "smime"))
 
+;; defuns that add the proper <#secure ...> tag to the top of the message body
+(defun mml-secure-message (method &optional sign)
+  (let ((mode (if sign "sign" "encrypt"))
+	insert-loc)
+    (mml-unsecure-message)
+    (save-excursion
+      (goto-char (point-max))
+      (cond ((re-search-backward
+	      (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
+	     (goto-char (setq insert-loc (match-end 0)))
+	     (unless (looking-at "<#secure")
+	       (mml-insert-tag
+		'secure 'method method 'mode mode)))
+	    (t (error
+		"The message is corrupted. No mail header separator"))))
+    (when (eql insert-loc (point))
+      (forward-line 1))))
+
+(defun mml-unsecure-message ()
+  (interactive)
+  (save-excursion
+    (goto-char (point-max))
+    (when (re-search-backward "^<#secure.*>\n" nil t)
+      (kill-region (match-beginning 0) (match-end 0)))))
+
+(defun mml-secure-message-sign-smime ()
+  "Add MML tag to encrypt/sign the entire message."
+  (interactive)
+  (mml-secure-message "smime" 'sign))
+
+(defun mml-secure-message-sign-pgp ()
+  "Add MML tag to encrypt/sign the entire message."
+  (interactive)
+  (mml-secure-message "pgp" 'sign))
+
+(defun mml-secure-message-sign-pgpmime ()
+  "Add MML tag to encrypt/sign the entire message."
+  (interactive)
+  (mml-secure-message "pgpmime" 'sign))
+
+(defun mml-secure-message-encrypt-smime ()
+  "Add MML tag to encrypt/sign the entire message."
+  (interactive)
+  (mml-secure-message "smime"))
+
+(defun mml-secure-message-encrypt-pgp ()
+  "Add MML tag to encrypt/sign the entire message."
+  (interactive)
+  (mml-secure-message "pgp"))
+
+(defun mml-secure-message-encrypt-pgpmime ()
+  "Add MML tag to encrypt/sign the entire message."
+  (interactive)
+  (mml-secure-message "pgpmime"))
+
 (provide 'mml-sec)
 
 ;;; mml-sec.el ends here
Index: lisp/mml.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mml.el,v
retrieving revision 6.47
diff -u -r6.47 mml.el
--- lisp/mml.el	2002/01/12 00:55:06	6.47
+++ lisp/mml.el	2002/01/19 07:39:35
@@ -143,6 +143,34 @@
     (while (and (not (eobp))
 		(not (looking-at "



             reply	other threads:[~2002-01-19  7:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-19  7:38 Josh Huber [this message]
2002-01-19  8:05 ` Josh Huber
2002-01-20  0:02   ` Lars Magne Ingebrigtsen
2002-01-22 16:34     ` Josh Huber
2002-01-22 22:36       ` Simon Josefsson
2002-01-22 22:59         ` Josh Huber
2002-01-20  0:01 ` Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bsfqeqnp.fsf@paradoxical.net \
    --to=huber@alum.wpi.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).