From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/64022 Path: news.gmane.org!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.gnus.general Subject: Re: Search for multipart/(signed|encrypted) in message-forward-make-body Date: Wed, 22 Nov 2006 16:25:54 +0900 Organization: Emacsen advocacy group Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1164180403 24797 80.91.229.2 (22 Nov 2006 07:26:43 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 22 Nov 2006 07:26:43 +0000 (UTC) Original-X-From: ding-owner+M12546@lists.math.uh.edu Wed Nov 22 08:26:42 2006 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GmmVB-0000ik-9i for ding-account@gmane.org; Wed, 22 Nov 2006 08:26:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1GmmUj-0002YM-GL; Wed, 22 Nov 2006 01:26:09 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1GmmUh-0002Xo-HR for ding@lists.math.uh.edu; Wed, 22 Nov 2006 01:26:07 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.63) (envelope-from ) id 1GmmUb-0003y3-8g for ding@lists.math.uh.edu; Wed, 22 Nov 2006 01:26:07 -0600 Original-Received: from orlando.hostforweb.net ([216.246.45.90]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1GmmUa-0002tB-00 for ; Wed, 22 Nov 2006 08:26:00 +0100 Original-Received: from [66.225.201.151] (port=40291 helo=mail.jpl.org) by orlando.hostforweb.net with esmtpa (Exim 4.52) id 1GmmUZ-0006PD-BD for ding@gnus.org; Wed, 22 Nov 2006 01:25:59 -0600 Original-To: ding@gnus.org X-Hashcash: 1:20:061122:ding@gnus.org::kPYnOjL3srZqvjH8:00001Lr8 X-Face: #kKnN,xUnmKia.'[pp`;Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu;B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux) Cancel-Lock: sha1:BCNtindIsnv7kvE2HrGYBM57i7M= X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - orlando.hostforweb.net X-AntiAbuse: Original Domain - gnus.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - jpl.org X-Source: X-Source-Args: X-Source-Dir: X-Spam-Score: -2.4 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:64022 Archived-At: --=-=-= >>>>> In >>>>> Reiner Steib wrote: >>> in `message-forward-make-body' we have: [...] >>> Shouldn't the search for multipart/(signed|encrypted) be restricted to >>> the headers? >> I don't think so. I tested your patch by forwarding again a >> forwarded message in which the forwarded part contains non-ASCII >> text and a gpg signature. > Ah, I didn't think of this case. Thanks for clarifying. > Wouldn't any text like "Content-Type: multipart/encrypted" in this > line give a false match? Probably this isn't harmful because the > message body looks nice with `message-forward-make-body-mml', but > `message-forward-make-body-mime' is safer. Is this correct? The complete version is below. :) The new function `message-signed-or-encrypted-p' dissects the message to forward and detects a signed or encrypted part by rightful means. Even if the function causes an error, Message chooses the raw mode safely. Could you test it? In addition, I'd like to install it to only the trunk if it is ok. WDYT? --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline (eval-and-compile (autoload 'mm-uu-dissect-text-parts "mm-uu") (autoload 'mm-uu-dissect "mm-uu")) (defun message-signed-or-encrypted-p (&optional handles) "Say whether the current buffer contains signed or encrypted message." (unless handles (if (setq handles (mm-dissect-buffer nil t)) (mm-uu-dissect-text-parts handles) (setq handles (mm-uu-dissect)))) ;; Check text/plain message in which there is a signed or encrypted ;; body that has been encoded by B or Q. (unless handles (let ((cur (current-buffer))) (with-temp-buffer (insert-buffer-substring cur) (when (setq handles (mm-dissect-buffer t t)) (if (and (prog1 (bufferp (car handles)) (mm-destroy-parts handles)) (equal (mm-handle-media-type handles) "text/plain")) (progn (mm-decode-content-transfer-encoding (mm-handle-encoding handles)) (setq handles (mm-uu-dissect))) (setq handles nil)))))) (when handles (prog1 (catch 'found (dolist (handle (if (stringp (car handles)) (if (member (car handles) '("multipart/signed" "multipart/encrypted")) (throw 'found t) (cdr handles)) (list handles))) (if (stringp (car handle)) (when (message-signed-or-encrypted-p handle) (throw 'found t)) (when (and (bufferp (car handle)) (equal (mm-handle-media-type handle) "message/rfc822")) (with-current-buffer (mm-handle-buffer handle) (when (message-signed-or-encrypted-p) (throw 'found t))))))) (mm-destroy-parts handles)))) (defun message-forward-make-body (forward-buffer &optional digest) ;; Put point where we want it before inserting the forwarded ;; message. (if message-forward-before-signature (message-goto-body) (goto-char (point-max))) (if digest (message-forward-make-body-digest forward-buffer) (if message-forward-as-mime (if (and message-forward-show-mml (not (and (eq message-forward-show-mml 'best) (with-current-buffer forward-buffer (condition-case nil (message-signed-or-encrypted-p) (error t)))))) (message-forward-make-body-mml forward-buffer) (message-forward-make-body-mime forward-buffer)) (message-forward-make-body-plain forward-buffer))) (message-position-point)) --=-=-=--