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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39230 in the body.
You can then email your comments to 39230 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#39230; Package emacs. (Tue, 21 Jan 2020 23:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jeremy Compostella <jeremy.compostella <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 21 Jan 2020 23:02:02 GMT) Full text and rfc822 format available.

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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39230; Package emacs. (Wed, 12 Feb 2020 18:19:02 GMT) Full text and rfc822 format available.

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

From: Jérémy Compostella <jeremy.compostella <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: [PATCH] Expand text/html regardless of it position in the MIME
 tree
Date: Wed, 12 Feb 2020 11:18:07 -0700
[Message part 1 (text/plain, inline)]
Hi,

I would really appreciate if I could receive a feedback on this patch.  I
can't send GPG HTML email because of this limitation and this is is also
blocking an issue reported of my org-msg module.

I have attached the patch here as I have fixed a typo in the commit
headline.

Let me know if I need to address this patch to another mailing list.

Regards,
Jeremy
.

On Tue, Jan 21, 2020 at 4:01 PM Jeremy Compostella <
jeremy.compostella <at> gmail.com> wrote:

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

-- 
« Si debugger, c'est supprimer des bugs, alors programmer ne peut être que
les ajouter » - Edsger Dijkstra
[Message part 2 (text/html, inline)]
[0001-Expand-text-html-regardless-of-its-position-in-the-M.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39230; Package emacs. (Wed, 19 Feb 2020 13:53:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jeremy Compostella <jeremy.compostella <at> gmail.com>
Cc: 39230 <at> debbugs.gnu.org
Subject: Re: bug#39230: [PATCH] Expand text/html regardless of it position
 in the MIME tree
Date: Wed, 19 Feb 2020 14:52:08 +0100
Jeremy Compostella <jeremy.compostella <at> gmail.com> writes:

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

Makes sense.  I've now applied the patch to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 19 Feb 2020 13:53:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 39230 <at> debbugs.gnu.org and Jeremy Compostella <jeremy.compostella <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 19 Feb 2020 13:53:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39230; Package emacs. (Fri, 28 Feb 2020 17:14:02 GMT) Full text and rfc822 format available.

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

From: Jérémy Compostella <jeremy.compostella <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: [PATCH] Expand text/html regardless of it position in the MIME
 tree
Date: Fri, 28 Feb 2020 10:13:41 -0700
[Message part 1 (text/plain, inline)]
An issue has been identified with this patch for which I wrote a fix.

I ran many tests and combination with this additional patch (see
attachement) and I could not find any issue left.

The reason I missed this obvious bug was my configuration using my
`org-msg' module which has an advice on
`mml-expand-html-into-multipart-related' to workaround the limitation
that my previous patch addresses.

The issue originates from the fact that the
`mml-expand-html-into-multipart-related' function returns a list of
list for an untouched part while it returns a simple list for expanded
multipart.  The recursive engine of
`mml-expand-all-html-into-multipart-related' is not handling
this.  Considering that the `mml-expand-html-into-multipart-related'
function is only used by mml as an internal function, IMO the best
approach is to make it consistent on its potential return values
structure. The patch I am submitting here makes
`mml-expand-html-into-multipart-related' returns a simple list
regardless of if it is a part or a multipart.

On Wed, Feb 12, 2020 at 11:18 AM Jérémy Compostella
<jeremy.compostella <at> gmail.com> wrote:
>
> Hi,
>
> I would really appreciate if I could receive a feedback on this patch.  I can't send GPG HTML email because of this limitation and this is is also blocking an issue reported of my org-msg module.
>
> I have attached the patch here as I have fixed a typo in the commit headline.
>
> Let me know if I need to address this patch to another mailing list.
>
> Regards,
> Jeremy
> .
>
> On Tue, Jan 21, 2020 at 4:01 PM Jeremy Compostella <jeremy.compostella <at> gmail.com> wrote:
>>
>> 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
>>
>
>
> --
> « Si debugger, c'est supprimer des bugs, alors programmer ne peut être que les ajouter » - Edsger Dijkstra



-- 
« Si debugger, c'est supprimer des bugs, alors programmer ne peut être
que les ajouter » - Edsger Dijkstra
[0001-Fix-nesting-list.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39230; Package emacs. (Sat, 14 Mar 2020 11:46:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jérémy Compostella <jeremy.compostella <at> gmail.com>
Cc: 39230 <at> debbugs.gnu.org
Subject: Re: bug#39230: [PATCH] Expand text/html regardless of it position
 in the MIME tree
Date: Sat, 14 Mar 2020 12:45:28 +0100
Jérémy Compostella <jeremy.compostella <at> gmail.com> writes:

> The reason I missed this obvious bug was my configuration using my
> `org-msg' module which has an advice on
> `mml-expand-html-into-multipart-related' to workaround the limitation
> that my previous patch addresses.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 39230 <at> debbugs.gnu.org and Jeremy Compostella <jeremy.compostella <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 14 Mar 2020 11:46:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 12 Apr 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 15 days ago.

Previous Next


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