GNU bug report logs - #39230
[PATCH] Expand text/html regardless of it position in the MIME tree

Previous Next

Package: emacs;

Reported by: Jeremy Compostella <jeremy.compostella <at> gmail.com>

Date: Tue, 21 Jan 2020 23:02:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jeremy Compostella <jeremy.compostella <at> gmail.com>
To: <bug-gnu-emacs <at> gnu.org>
Subject: [PATCH] Expand text/html regardless of it position in the MIME tree
Date: Tue, 21 Jan 2020 16:01:40 -0700
If the text/html part is not the unique part of the email,
mml-generate-mime does not expand it to a related multipart. This
break uses cases like PGP signing of an HTML email including images.

For instance, if you compose an email with the <multipart sign=pgpmime>
and a <part type="text/html" disposition=inline>, the second part is
not expanded into a multipart related and the images are not included.

Signed-off-by: Jeremy Compostella <jeremy.compostella <at> gmail.com>
---
 lisp/gnus/mml.el | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el
index cdd8f3d3a5..3d86c5bc40 100644
--- a/lisp/gnus/mml.el
+++ b/lisp/gnus/mml.el
@@ -487,11 +487,8 @@ type detected."
 		 (= (length cont) 1)
 		 content-type)
 	(setcdr (assq 'type (cdr (car cont))) content-type))
-      (when (and (consp (car cont))
-		 (= (length cont) 1)
-		 (fboundp 'libxml-parse-html-region)
-		 (equal (cdr (assq 'type (car cont))) "text/html"))
-	(setq cont (mml-expand-html-into-multipart-related (car cont))))
+      (when (fboundp 'libxml-parse-html-region)
+	(setq cont (mapcar 'mml-expand-all-html-into-multipart-related cont)))
       (prog1
 	  (with-temp-buffer
 	    (set-buffer-multibyte nil)
@@ -510,6 +507,18 @@ type detected."
 	    (buffer-string))
 	(setq message-options options)))))
 
+(defun mml-expand-all-html-into-multipart-related (cont)
+  (cond ((and (eq (car cont) 'part)
+	      (equal (cdr (assq 'type cont)) "text/html"))
+	 (mml-expand-html-into-multipart-related cont))
+	((eq (car cont) 'multipart)
+	 (let ((cur (cdr cont)))
+	   (while (consp cur)
+	     (setcar cur (mml-expand-all-html-into-multipart-related (car cur)))
+	     (setf cur (cdr cur))))
+	 cont)
+	(t cont)))
+
 (defun mml-expand-html-into-multipart-related (cont)
   (let ((new-parts nil)
 	(cid 1))
-- 
2.24.1





This bug report was last modified 5 years and 71 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.