Gnus development mailing list
 help / color / mirror / Atom feed
* Buttonizing and decoding based on message part contents?
@ 2003-12-16 18:33 Lloyd Zusman
  2003-12-16 23:08 ` Jesper Harder
  0 siblings, 1 reply; 11+ messages in thread
From: Lloyd Zusman @ 2003-12-16 18:33 UTC (permalink / raw)


I know that I can use `mm-content-transfer-encoding-defaults',
`mm-inline-override-types', and `mm-discouraged-alternatives' to control
how various message parts are buttonized and decoded.

I'm wondering if it's also possible to go one step further: to look
inside of the message part itself and use the contents to control these
things.

What I want to do is to look into each part and see if it contains a
block of text between the markers "-----BEGIN PGP MESSAGE-----" and
"-----END PGP MESSAGE-----", and if so, to either buttonize it or force
it to be decoded via pgg (or both).

Is there some sort of hook mechanism that will allow me to install an
optional function to test each message part and as a result of this
test, to set its buttonizing or decoding attributes?  If so, that would
make it easy for me to implement this functionality.

Or perhaps is there another way to do this?

Thanks in advance.

-- 
 Lloyd Zusman
 ljz@asfast.com




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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-16 18:33 Buttonizing and decoding based on message part contents? Lloyd Zusman
@ 2003-12-16 23:08 ` Jesper Harder
  2003-12-17 13:19   ` Lloyd Zusman
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Harder @ 2003-12-16 23:08 UTC (permalink / raw)


Lloyd Zusman <ljz@asfast.com> writes:

> What I want to do is to look into each part and see if it contains a
> block of text between the markers "-----BEGIN PGP MESSAGE-----" and
> "-----END PGP MESSAGE-----", and if so, to either buttonize it or force
> it to be decoded via pgg (or both).
>
> Is there some sort of hook mechanism that will allow me to install an
> optional function to test each message part and as a result of this
> test, to set its buttonizing or decoding attributes?

No. `mm-uu-dissect' which is the function responsible for detecting
this is only applied to single part text/plain.

I think this feature has been requested several times (and ISTR
previous discussions here).  Look around line 4495 in gnus-art.el if
you'd like to experiment with it.

> Or perhaps is there another way to do this?

Another possibility could be to do it as a part of article washing --
something like the removed `article-hide-pgp' from Gnus 5.9.



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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-16 23:08 ` Jesper Harder
@ 2003-12-17 13:19   ` Lloyd Zusman
  2003-12-17 13:49     ` Jesper Harder
  0 siblings, 1 reply; 11+ messages in thread
From: Lloyd Zusman @ 2003-12-17 13:19 UTC (permalink / raw)


Jesper Harder <harder@ifa.au.dk> writes:

> Lloyd Zusman <ljz@asfast.com> writes:
>
>> What I want to do is to look into each part and see if it contains a
>> block of text between the markers "-----BEGIN PGP MESSAGE-----" and
>> "-----END PGP MESSAGE-----", and if so, to either buttonize it or force
>> it to be decoded via pgg (or both).
>>
>> Is there some sort of hook mechanism that will allow me to install an
>> optional function to test each message part and as a result of this
>> test, to set its buttonizing or decoding attributes?
>
> No. `mm-uu-dissect' which is the function responsible for detecting
> this is only applied to single part text/plain.
>
> I think this feature has been requested several times (and ISTR
> previous discussions here).  Look around line 4495 in gnus-art.el if
> you'd like to experiment with it.

I'll take a look.


>> Or perhaps is there another way to do this?
>
> Another possibility could be to do it as a part of article washing --
> something like the removed `article-hide-pgp' from Gnus 5.9.

Does anyone know why that washing function was removed?

Thank you very much for the tips.


-- 
 Lloyd Zusman
 ljz@asfast.com




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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-17 13:19   ` Lloyd Zusman
@ 2003-12-17 13:49     ` Jesper Harder
  2003-12-17 14:04       ` Lloyd Zusman
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Harder @ 2003-12-17 13:49 UTC (permalink / raw)


Lloyd Zusman <ljz@asfast.com> writes:

> Jesper Harder <harder@ifa.au.dk> writes:
>
>> Another possibility could be to do it as a part of article washing
>> -- something like the removed `article-hide-pgp' from Gnus 5.9.
>
> Does anyone know why that washing function was removed?

It was obsoleted by the new built-in pgp functionality in Oort.



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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-17 13:49     ` Jesper Harder
@ 2003-12-17 14:04       ` Lloyd Zusman
  2003-12-17 15:13         ` Jesper Harder
  0 siblings, 1 reply; 11+ messages in thread
From: Lloyd Zusman @ 2003-12-17 14:04 UTC (permalink / raw)


Jesper Harder <harder@ifa.au.dk> writes:

> Lloyd Zusman <ljz@asfast.com> writes:
>
>> Jesper Harder <harder@ifa.au.dk> writes:
>>
>>> Another possibility could be to do it as a part of article washing
>>> -- something like the removed `article-hide-pgp' from Gnus 5.9.
>>
>> Does anyone know why that washing function was removed?
>
> It was obsoleted by the new built-in pgp functionality in Oort.

But this particular piece of obsolete functionality has no replacement,
correct?

-- 
 Lloyd Zusman
 ljz@asfast.com




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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-17 14:04       ` Lloyd Zusman
@ 2003-12-17 15:13         ` Jesper Harder
  2003-12-17 15:43           ` Lloyd Zusman
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Harder @ 2003-12-17 15:13 UTC (permalink / raw)


Lloyd Zusman <ljz@asfast.com> writes:

> Jesper Harder <harder@ifa.au.dk> writes:

>> [article-hide-pgp]
>
>> It was obsoleted by the new built-in pgp functionality in Oort.
>
> 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.

Its main purpose was just to hide plain old PGP cruft from normal
articles, because Gnus lacked any real PGP support.

The problem is really that people stick old-style PGP inside MIME
parts -- the purpose of MIME is to get rid of silly magic strings like
"-----BEGIN PGP MESSAGE".  In a multipart message you should use
pgp/mime.



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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-17 15:13         ` Jesper Harder
@ 2003-12-17 15:43           ` Lloyd Zusman
  2003-12-17 22:13             ` Jesper Harder
  0 siblings, 1 reply; 11+ messages in thread
From: Lloyd Zusman @ 2003-12-17 15:43 UTC (permalink / raw)


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.
>
> [ ... ]
>
> The problem is really that people stick old-style PGP inside MIME
> parts -- the purpose of MIME is to get rid of silly magic strings like
> "-----BEGIN PGP MESSAGE".  In a multipart message you should use
> pgp/mime.

Yes, in an ideal world that would be the way it's done.  I usually send
out messages in that format; but sadly, there are lots of people who
send messages to _me_ who use the "-----BEGIN PGP MESSAGE-----" magic
string within text/plain or application/octet-stream attachments.  The
chances of my getting each of these people to change their software and
resubmit each individual encrypted message of theirs to me in a timely
fashion is next to nil.

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.


-- 
 Lloyd Zusman
 ljz@asfast.com




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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-17 15:43           ` Lloyd Zusman
@ 2003-12-17 22:13             ` Jesper Harder
  2003-12-18 17:30               ` Lloyd Zusman
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Harder @ 2003-12-17 22:13 UTC (permalink / raw)


[-- 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

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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-17 22:13             ` Jesper Harder
@ 2003-12-18 17:30               ` Lloyd Zusman
  2003-12-19  1:17                 ` Jesper Harder
  0 siblings, 1 reply; 11+ messages in thread
From: Lloyd Zusman @ 2003-12-18 17:30 UTC (permalink / raw)


Jesper Harder <harder@ifa.au.dk> writes:

> Lloyd Zusman <ljz@asfast.com> writes:
>
>> Jesper Harder <harder@ifa.au.dk> writes:
>>
>>> [ ... ]
>>>
>>> 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.

Thank you.  I'll give it a try.


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

OK.  That makes sense.

In addition to trying the patch that you have enclosed, I also still
want to try the "hook" idea that I mentioned above.  I'll see if I can
do this.

A question: if I write a washing-type function that traverses the MIME
structure of a message and calls a hook for each part, what should I do
within this hook in order to cause each of the following outcomes? ...

1. Buttonize the message part.

2. Override the part's MIME type with my own setting.  This will allow a
   text/plain or application/octet-stream part that contains delimiters
   such as "-----BEGIN PGP MESSAGE-----" to be handled via the code that
   already exists for application/pgp-encrypted parts.

Thanks.

-- 
 Lloyd Zusman
 ljz@asfast.com




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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-18 17:30               ` Lloyd Zusman
@ 2003-12-19  1:17                 ` Jesper Harder
  2003-12-19 18:26                   ` Lloyd Zusman
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Harder @ 2003-12-19  1:17 UTC (permalink / raw)


Lloyd Zusman <ljz@asfast.com> writes:

> A question: if I write a washing-type function that traverses the MIME
> structure of a message and calls a hook for each part, what should I do
> within this hook in order to cause each of the following outcomes? ...
>
> 1. Buttonize the message part.
>
> 2. Override the part's MIME type with my own setting.  This will allow a
>    text/plain or application/octet-stream part that contains delimiters
>    such as "-----BEGIN PGP MESSAGE-----" to be handled via the code that
>    already exists for application/pgp-encrypted parts.

I think this will be hard to do with a washing function.  It's applied
too late.

You need to look at what `mm-uu-dissect' and `gnus-display-mime' does.



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

* Re: Buttonizing and decoding based on message part contents?
  2003-12-19  1:17                 ` Jesper Harder
@ 2003-12-19 18:26                   ` Lloyd Zusman
  0 siblings, 0 replies; 11+ messages in thread
From: Lloyd Zusman @ 2003-12-19 18:26 UTC (permalink / raw)


Jesper Harder <harder@ifa.au.dk> writes:

> Lloyd Zusman <ljz@asfast.com> writes:
>
>> A question: if I write a washing-type function that traverses the MIME
>> structure of a message and calls a hook for each part, what should I do
>> within this hook in order to cause each of the following outcomes? ...
>>
>> 1. Buttonize the message part.
>>
>> 2. Override the part's MIME type with my own setting.  This will allow a
>>    text/plain or application/octet-stream part that contains delimiters
>>    such as "-----BEGIN PGP MESSAGE-----" to be handled via the code that
>>    already exists for application/pgp-encrypted parts.
>
> I think this will be hard to do with a washing function.  It's applied
> too late.
>
> You need to look at what `mm-uu-dissect' and `gnus-display-mime' does.

I'll check those out, thanks.

-- 
 Lloyd Zusman
 ljz@asfast.com




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

end of thread, other threads:[~2003-12-19 18:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-16 18:33 Buttonizing and decoding based on message part contents? 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
2003-12-18 17:30               ` Lloyd Zusman
2003-12-19  1:17                 ` Jesper Harder
2003-12-19 18:26                   ` Lloyd Zusman

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