mail fails to properly display a multipart/mixed content

Created on 5 Oct 2020  Â·  2Comments  Â·  Source: nextcloud/mail

Expected behavior

mail should be able to properly display any kind of multiplart/mixed html body

Actual behavior

I have an instance of an email containing some multipart/mixed parts and mail doesn't display it properly.

The multipart/mixed content contains 5 parts:

--Apple-Mail=_CC09C570-1247-4B0D-B260-64D5EC638046
Content-Type: multipart/mixed;
    boundary="Apple-Mail=_860B4056-4AB3-4A2E-862D-EAE76F495049"

--Apple-Mail=_860B4056-4AB3-4A2E-862D-EAE76F495049
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
    charset=utf-8

-Apple-Mail=_860B4056-4AB3-4A2E-862D-EAE76F495049
Content-Disposition: inline;
    filename=image001.jpg
Content-Type: image/jpeg;
    x-unix-mode=0666;
    name="image001.jpg"
Content-Transfer-Encoding: base64

--Apple-Mail=_860B4056-4AB3-4A2E-862D-EAE76F495049
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
    charset=utf-8

--Apple-Mail=_860B4056-4AB3-4A2E-862D-EAE76F495049
Content-Disposition: attachment;
    filename="PROPOSITION D'ACCORD.docx"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document;
    x-unix-mode=0666;
    name="PROPOSITION D'ACCORD.docx"
Content-Transfer-Encoding: base64

--Apple-Mail=_860B4056-4AB3-4A2E-862D-EAE76F495049
Content-Transfer-Encoding: 7bit
Content-Type: text/html;
    charset=us-ascii

Specifically, mail only displays the 1st part of the content and not the 3rd part which also contains important text.

I suspect it is due to the inline image/jpeg part. I'm investigating

Mail app

Mail app version: master (1.5)

0. to triage bug

All 2 comments

It turns out the issue originates from the HTMLPurifier in:

https://github.com/nextcloud/mail/blob/d5c7dc5a98f7ec351f9c8ef2306b976fb6311201/lib/Service/Html.php#L141

Just before this line, the body is correct (about 150.000 chars) and just after it isn't (about 7000 chars)

It's definitively in HTMLPurifier.

Here's the resulting output:

Cher Monsieur,
REDACTED
<div><br /></div>
<div>
   Bien à Vous<br />
   <div><br /></div>
   <div>
      <br />
      <div>
         <span class="Apple-style-span" style="border-collapse:separate;color:rgb(0,0,0);font-family:Verdana;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;color:rgb(0,0,0);font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;color:rgb(0,0,0);font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"></span></span></span></span></span></span></span></span></span></span></span></span>
         <div>
            <span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"></span>
            <div>
               <span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"></span>
               <div>
                  <span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="font-family:Calibri, sans-serif;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="font-family:Calibri, Verdana, Helvetica, Arial;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="font-family:Calibri, Verdana, Helvetica, Arial;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span class="Apple-style-span" style="border-collapse:separate;font-family:Verdana;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
                  <div style="font-weight:normal;color:rgb(0,0,0);"><span>     </span></div>
                  <div><span><span></span><span></span><span></span><span></span><span></span><br class="Apple-interchange-newline" /><span></span><span></span><span style="color:rgb(0,0,0);"></span><span></span><span></span><span></span><span></span><span style="color:rgb(0,0,0);font-weight:normal;"></span><span style="font-weight:normal;"></span><span style="font-weight:normal;"></span><span></span></span></div>
               </div>
            </div>
         </div>
      </div>
   </div>
</div>

while the input is:

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   </head>
   <body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
      Cher Monsieur,
 REDACTED
     <div class=""><br class=""></div>
      <div class="">
         Bien à Vous<br class="">
         <div class=""><br class=""></div>
         <div class="">
            <br class="">
            <div class="">
               <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Verdana; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;  ">
                  <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Verdana; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;  ">
                     <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Verda
STRIPPED CONTENT (>100.000 bytes)
               <br class="">
               <div class="">Début du message réexpédié :</div>
               <br class="Apple-interchange-newline">
               <div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">De: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">"Fanny Piron" &lt;<a href="mailto:[email protected]" class="">[email protected]</a>&gt;<br class=""></span></div>
               <div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Objet: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class=""><b class="">RE: Bollu-Delande</b><br class=""></span></div>
               <div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Date: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">2 octobre 2020 à 14:12:47 UTC+2<br class=""></span></div>
               <div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">À: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">"'Julie Copin'" &lt;<a href="mailto:[email protected]" class="">[email protected]</a>&gt;<br class=""></span></div>
               <br class="">
               <div class="">
                  <div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
                     <div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;, serif;" class="">
                        Mon Cher Confrère,
                        <o:p class=""></o:p>
                     </div>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MariusBluem picture MariusBluem  Â·  3Comments

benks-io picture benks-io  Â·  4Comments

jancborchardt picture jancborchardt  Â·  4Comments

fsedarkalex picture fsedarkalex  Â·  5Comments

Quix0r picture Quix0r  Â·  5Comments