Html images, multipart message, Content-ID

POP Peeper: Tech support, suggestions, discussion, etc.
Post Reply
Bilbo
Posts: 3
Joined: Wed Oct 28, 2015 12:44 pm

Html images, multipart message, Content-ID

Post by Bilbo »

There is apparently a bug in rendering multipart messages with image data attached as parts? Mozilla-lineage email clients do not show the bug. Major webmail clients other than GMail also render the message correctly.

From experimentation, the problem has to do with the length of the Content-ID, which links the text/html part with any image/* parts. When the string is five characters or shorter, the related images are displayed correctly. When the string is six characters or longer, the related images are usually not displayed.

The message structure is below. An offending message is attached. Open the .EML file in various clients to see the problem. Notice there are four image-parts (all designated for embedding in the html, not as traditional attachments), but the html document has six image elements, all of which call for image data in other message-parts. This is not part of the problem.

Non-PP viewers correctly render each single image-part in more than one place in the html document. PP does the same thing, for image elements with Content-IDs shorter than six digits. But when the Content-ID is longer than five digits, PP fails to find the image data, and instead shows its placeholder icon (white X on blank background inside black border).

The Content-ID string is specified to be generated by a function, so that it is long enough to be unique, and include the unixTime when it was created. For example: 163348439864.6904.1647111843163476077@Machine

Obviously there are several reasons why html email messages use explicit src="<url>" for images instead of carrying the image data as part of the message, and flaky rendering could be one of them. But if this bug counts as another reason to upgrade the html engine, then put it on that list :)
-- message structure --
From: Frm <Box@Lcl.org>
To: dummy
Subject: dummy
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="===============1787737246=="

--===============1787737246==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit

Salut!
[1] http://www.yummly.com/recipe/Roasted-As ... ous-203718

--===============1787737246==
MIME-Version: 1.0
Content-Type: multipart/related; boundary="===============0938356429=="

--===============0938356429==
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit

<html>
<head></head>
<body>
<p>Salut!</p>
<p>Cela ressemble un excellent
<a href="http://www.yummly.com/recipe/Roasted-As ... >recipe</a> dejeuner.
</p>
<img src="cid:1" />
<img src="cid:2" />
<img src="cid:69708" />
<img src="cid:54942" />
<img src="cid:1" />
<img src="cid:2" />
</body>
</html>

--===============0938356429==
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-ID: 1
MIME-Version: 1.0
Content-Disposition: inline

<base64 encoded-image data>

--===============0938356429==
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-ID: 2
MIME-Version: 1.0
Content-Disposition: inline

<base64 encoded-image data>

--===============0938356429==
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-ID: 69708
MIME-Version: 1.0
Content-Disposition: inline

<base64 encoded-image data>

--===============0938356429==
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-ID: 54942
MIME-Version: 1.0
Content-Disposition: inline

<base64 encoded-image data>

--===============0938356429==--

--===============1787737246==--
Attachments
Demo.TXT
Rename from .TXT to .EML
(60.11 KiB) Downloaded 129 times
User avatar
Jeff
Admin / Developer
Posts: 9226
Joined: Sat Sep 08, 2001 9:46 pm

Re: Html images, multipart message, Content-ID

Post by Jeff »

Thanks for reporting this. I was getting very mixed results in my testing, until I figured out what the problem is.

The source of the problem is here:

Code: Select all

    <img src="cid:1" />
    <img src="cid:2" />
    <img src="cid:163348439864.6904.16471118431634760773@Machine" />
    <img src="cid:163348439864.6904.6653841520524613463@Machine" />
Specifically, it's "cid:1" causing the problem in this case. What's happening is that the "1" is getting pattern-matched into the longer cid's -- because they both start with "1". If you modify "cid:1633..." to "cid:3633..." (and modify the corresponding header of the image part), then that picture will display correctly.
User avatar
Jeff
Admin / Developer
Posts: 9226
Joined: Sat Sep 08, 2001 9:46 pm

Re: Html images, multipart message, Content-ID

Post by Jeff »

Update: this has been fixed and will be in v5.2.1; I will likely push this to the early release channel soon (early release is currently on v5.2.0).

This bug has very likely been around since the beginning, so thanks again for finding and reporting it!
Post Reply