Gnus development mailing list
 help / color / mirror / Atom feed
From: Jesper Harder <harder@ifa.au.dk>
Subject: Re: Buttonizing and decoding based on message part contents?
Date: Wed, 17 Dec 2003 23:13:56 +0100	[thread overview]
Message-ID: <m3zndr6qjf.fsf@defun.localdomain> (raw)
In-Reply-To: <m365gf30xk.fsf@asfast.com> (Lloyd Zusman's message of "Wed, 17 Dec 2003 10:43:03 -0500")

[-- Attachment #1: Type: text/plain, Size: 1050 bytes --]

Lloyd Zusman <ljz@asfast.com> writes:

> Jesper Harder <harder@ifa.au.dk> writes:
>
>> Lloyd Zusman <ljz@asfast.com> writes:
>>
>>> But this particular piece of obsolete functionality has no
>>> replacement, correct?
>>
>> Well, I don't actually know if `article-hide-pgp' did anything
>> useful for multiparts.

It does, at least for text/plain parts.  Try the attached patch.

> If there was a hook function that gets called for each message part
> (and which allows me to set the display and buttonizing status for
> each part), I could then write my own, personal code to handle this
> case, and at the same time avoid polluting the Gnus code base with
> this anachronism.

The bad thing isn't pollution, but that the approach
`article-hide-pgp' uses doesn't really solve the problems.  It just
hides them, viz.

· It doesn't allow you to actually verify the signatures.
· It doesn't work for encrypted parts.
· It doesn't necessarily (I haven't tested) solve the related problem
  of format=flowed & old-style PGP.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gnus-art.el.diff --]
[-- Type: text/x-patch, Size: 3568 bytes --]

--- gnus/lisp/gnus-art.el	Tue Nov 25 12:54:07 2003
+++ cvsgnus/lisp/gnus-art.el	Wed Dec 17 23:11:33 2003
@@ -562,8 +562,12 @@
   :type 'hook
   :group 'gnus-article-various)
 
-(make-obsolete-variable 'gnus-article-hide-pgp-hook
-			"This variable is obsolete in Gnus 5.10.")
+;(make-obsolete-variable 'gnus-article-hide-pgp-hook
+;			"This variable is obsolete in Gnus 5.10.")
+(defcustom gnus-article-hide-pgp-hook nil
+  "*A hook called after successfully hiding a PGP signature."
+  :type 'hook
+  :group 'gnus-article-various)
 
 (defcustom gnus-article-button-face 'bold
   "Face used for highlighting buttons in the article buffer.
@@ -985,8 +989,16 @@
   :link '(custom-manual "(gnus)Customizing Articles")
   :type gnus-article-treat-custom)
 
-(make-obsolete-variable 'gnus-treat-strip-pgp
-			"This option is obsolete in Gnus 5.10.")
+;(make-obsolete-variable 'gnus-treat-strip-pgp
+;			"This option is obsolete in Gnus 5.10.")
+
+(defcustom gnus-treat-strip-pgp t
+  "Strip PGP signatures.
+Valid values are nil, t, `head', `last', an integer or a predicate.
+See Info node `(gnus)Customizing Articles' for details."
+  :group 'gnus-article-treat
+  :link '(custom-manual "(gnus)Customizing Articles")
+  :type gnus-article-treat-custom)
 
 (defcustom gnus-treat-strip-pem nil
   "Strip PEM signatures.
@@ -1396,6 +1408,7 @@
     (gnus-treat-hide-signature gnus-article-hide-signature)
     (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
     (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
+    (gnus-treat-strip-pgp gnus-article-hide-pgp)
     (gnus-treat-strip-pem gnus-article-hide-pem)
     (gnus-treat-from-picon gnus-treat-from-picon)
     (gnus-treat-mail-picon gnus-treat-mail-picon)
@@ -2416,6 +2429,42 @@
 		 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
 	    (delete-region (match-beginning 1) (match-end 1))))))))
 
+(defun article-hide-pgp ()
+  "Remove any PGP headers and signatures in the current article."
+  (interactive)
+  (save-excursion
+    (save-restriction
+      (let ((inhibit-point-motion-hooks t)
+	    buffer-read-only beg end)
+	(article-goto-body)
+	;; Hide the "header".
+	(when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
+	  (gnus-add-wash-type 'pgp)
+	  (delete-region (match-beginning 0) (match-end 0))
+	  ;; Remove armor headers (rfc2440 6.2)
+	  (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
+				     (point)))
+	  (setq beg (point))
+	  ;; Hide the actual signature.
+	  (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
+	       (setq end (1+ (match-beginning 0)))
+	       (delete-region
+		end
+		(if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
+		    (match-end 0)
+		  ;; Perhaps we shouldn't hide to the end of the buffer
+		  ;; if there is no end to the signature?
+		  (point-max))))
+	  ;; Hide "- " PGP quotation markers.
+	  (when (and beg end)
+	    (narrow-to-region beg end)
+	    (goto-char (point-min))
+	    (while (re-search-forward "^- " nil t)
+	      (delete-region
+	       (match-beginning 0) (match-end 0)))
+	    (widen))
+	  (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
+
 (defun article-hide-pem (&optional arg)
   "Toggle hiding of any PEM headers and signatures in the current article.
 If given a negative prefix, always show; if given a positive prefix,
@@ -3482,6 +3531,7 @@
      article-wash-html
      article-unsplit-urls
      article-hide-list-identifiers
+     article-hide-pgp
      article-strip-banner
      article-babel
      article-hide-pem

  reply	other threads:[~2003-12-17 22:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-16 18:33 Lloyd Zusman
2003-12-16 23:08 ` Jesper Harder
2003-12-17 13:19   ` Lloyd Zusman
2003-12-17 13:49     ` Jesper Harder
2003-12-17 14:04       ` Lloyd Zusman
2003-12-17 15:13         ` Jesper Harder
2003-12-17 15:43           ` Lloyd Zusman
2003-12-17 22:13             ` Jesper Harder [this message]
2003-12-18 17:30               ` Lloyd Zusman
2003-12-19  1:17                 ` Jesper Harder
2003-12-19 18:26                   ` Lloyd Zusman

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=m3zndr6qjf.fsf@defun.localdomain \
    --to=harder@ifa.au.dk \
    /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).