Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] make sign/encrypt operate on the whole message
@ 2002-01-19  7:38 Josh Huber
  2002-01-19  8:05 ` Josh Huber
  2002-01-20  0:01 ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 7+ messages in thread
From: Josh Huber @ 2002-01-19  7:38 UTC (permalink / 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 "



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-01-22 22:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-19  7:38 [PATCH] make sign/encrypt operate on the whole message Josh Huber
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

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).