Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List unrefered inline images as attachments #5051

Open
rcubetrac opened this issue Oct 31, 2012 · 19 comments
Open

List unrefered inline images as attachments #5051

rcubetrac opened this issue Oct 31, 2012 · 19 comments

Comments

@rcubetrac
Copy link

Reported by zamri on 31 Oct 2012 08:53 UTC as Trac ticket #1488783

See attachment. I have opened it in Thunderbird and it contains no text message but 1 gif image as an attachment. In RC, I dont see any attachment.

Keywords: attachment, design behaviour
Migrated-From: http://trac.roundcube.net/ticket/1488783

@rcubetrac
Copy link
Author

Comment by @alecpl on 31 Oct 2012 09:04 UTC

In other words this is a request to add to attachments list inline related images that aren't used in HTML part (part can not exist, be empty, or just doesn't refer to the image by its content-id).

@rcubetrac
Copy link
Author

Milestone changed by @alecpl on 31 Oct 2012 09:04 UTC

0.9-beta => later

@rcubetrac
Copy link
Author

Summary changed by @alecpl on 31 Oct 2012 09:04 UTC

No attachment in roundcube

List unrefered inline images as attachments

@rcubetrac
Copy link
Author

Comment by zamri on 1 Nov 2012 02:13 UTC

Another example added. Pls see attachment 12.zip. This one it has 'something' in the message that it doesn't show in RC and Thunderbird.

@rcubetrac
Copy link
Author

Comment by @alecpl on 21 Mar 2013 11:53 UTC

Consider also listing images that are referred, but not displayed - text part is used for display. See #1489003.

@rcubetrac
Copy link
Author

Comment by @alecpl on 21 Mar 2013 11:55 UTC

12.zip source is malformed. There's no headers and there's HTML content in plain/text part.

@rcubetrac
Copy link
Author

Comment by xenon on 22 Mar 2013 09:43 UTC

I'm not sure how is 'right way' for displaying inline files, but quote for RFC:

2.1 The Inline Disposition Type

A bodypart should be marked `inline' if it is intended ''to be
displayed automatically upon display of the message. '' Inline
bodyparts should be presented in the order in which they occur,
subject to the normal semantics of multipart messages.

http://tools.ietf.org/html/rfc2183

Looks like even if image is not referenced from HTML part, it still should be displayed.

Also, tested message from #1489003 on different software. Webmails: Gmail, Squirrelmail
MUA: kmail, thunderbird

all of them (but not RoundCube) displays inline images.

@rcubetrac
Copy link
Author

Comment by @alecpl on 22 Mar 2013 09:58 UTC

We have a setting in Roundcube with which user can decide to display them or not below the message body. It is not so simple as RFC says. What if the message is multipart/alternative? What's inline for HTML part don't need to be inline for text.

@rcubetrac
Copy link
Author

Comment by @alecpl on 16 Apr 2015 19:41 UTC

Another sample in #1490355.

@Pesticles
Copy link

Pesticles commented Apr 22, 2016

I've encountered this issue in Roundcube v1.1.4-4.11.el7.kolab_3.4

Here's a dirty patch I wrote which "fixes" the issue by forcing all inline attachments to be displayed as normal attachments:

--- ./program/lib/Roundcube/rcube_message.php.orig  2016-04-22 11:31:34.919974077 +1200
+++ ./program/lib/Roundcube/rcube_message.php   2016-04-22 11:31:04.678976612 +1200
@@ -753,6 +753,7 @@
                             $mail_part->content_location = $mail_part->headers['content-base'] . $mail_part->headers['content-location'];

                         $this->inline_parts[] = $mail_part;
+                        $this->attachments[] = $mail_part;
                     }
                     // regular attachment with valid content type
                     // (content-type name regexp according to RFC4288.4.2)

Note, this version has the option "Display attached images below message" which appears to be related to this, however I can find nowhere in the code where the option actually does anything.

It's possible the above could be handled better further down in that file, but the above works nicely so I'm going to stop there.

@ner00
Copy link

ner00 commented May 4, 2018

I wasnt't aware that this "issue" was going on for so long.
I'm using latest 1.3.6 version and also have issues with inline images not showing either inline nor as attachments. I ended up by adapting the useful suggestion above from @Pesticles that solved the issue:

                            $mail_part->content_location = $mail_part->headers['content-base'] . $mail_part->headers['content-location'];

                        $this->add_part($mail_part, 'inline');
+                       $this->add_part($mail_part, 'attachment');
                    }
                    // regular attachment with valid content type
                    // (content-type name regexp according to RFC4288.4.2)

@dupgit
Copy link

dupgit commented Nov 30, 2018

1.3.8 Still have this issue. Nor @Pesticles or @ner00 suggestions seems working in this version.
By the way : in this version inline image are correctly shown in compose window but not in the reading window.

@uj
Copy link

uj commented Mar 22, 2019

This happens when I send a picture from an Android phone with sms to an email address. The image does not show up at all in RoundCube, either as inline nor as an attachment on the side. Just nothing at all.

The above fixes do not work with Roundcube 1.3.7 and later.

I found that I can fix it with the patch below in v1.3.7 (and this should work in later versions as well):

In the file lib/Roundcube/rcube_message.php:


                // calendar part not marked as attachment (#1490325)
                else if ($part_mimetype == 'text/calendar') {
                    if (!$mail_part->filename) {
                        $mail_part->filename = 'calendar.ics';
                    }

                    $this->add_part($mail_part, 'attachment');
                }
+		//ADD THIS ELSE STATEMENT TO FIX MISSING ATTACHMENTS
+		else
+			{                    
+			$this->add_part($mail_part, 'attachment');
+			}
            }
            // if this was a related part try to resolve references
            if (preg_match('/^multipart\/(related|relative)/', $mimetype) && count($this->inline_parts)) {
                $a_replaces = array();
                $img_regexp = '/^image\/(gif|jpe?g|png|tiff|bmp|svg)/';


@dupgit
Copy link

dupgit commented Mar 27, 2019

@uj: It still seem not to work in my case.

The example message I use has the following fields:

Content-Type: multipart/mixed;
	boundary=Apple-Mail-61171DF1-C781-4C1E-8298-28527926F333

…

 --Apple-Mail-61171DF1-C781-4C1E-8298-28527926F333
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: 7bit

…

--Apple-Mail-61171DF1-C781-4C1E-8298-28527926F333
Content-Type: image/png;
	name=aglpinhgiccnbjic.png;
	x-apple-part-url="[email protected]"
Content-Disposition: inline;
	filename=aglpinhgiccnbjic.png
Content-Transfer-Encoding: base64

The image is not showed inlined.

@ner00
Copy link

ner00 commented Jun 22, 2020

I had updated Roundcube to v1.4.4 and forgot all about this just to have it happen today with an e-mail and the same approach I used for v1.3.6 (#5051 (comment)) still worked fine for me in v1.4.4.

As a side note, opening the EML in Thunderbird displays the inline images as attachments, whereas Roundcube does not display them at all.

Below is an example of the EML code which I came accross today. Message was originally sent from Gmail - unsure if web or desktop/mobile client; then received and forwarded by Outlook 2007 client/Exchange 2000 server, lastly received by hMailServer and viewed on Roundcube 1.4.4):

Return-Path: [email protected]
Received: from domain.local (server1.domain.local [192.168.12.34])
	by server2.domain.local with ESMTP
	; Fri, 19 Jun 2020 17:39:53 +0100
Content-class: urn:content-classes:message
Return-Receipt-To: "Person A" <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/related;
	boundary="----_=_NextPart_001_01D64658.43C8EDDA";
	type="multipart/alternative"
Disposition-Notification-To: "Person A" <[email protected]>
Subject: =?UTF-8?B?Rlc6IFRoaXMgaXMgYSB0ZXN0IHN1YmplY3Q?=
Date: Fri, 19 Jun 2020 17:39:55 +0100
X-MimeOLE: Produced By Microsoft Exchange V6.5
Message-ID: <[email protected]>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: =?UTF-8?B?VGhpcyBpcyBhIHRlc3Qgc3ViamVjdA==?=
Thread-Index: AdZGV/0KnZLHSJgdQGOvII69WGii0QAAEPMw
From: "Person A" <[email protected]>
To: "Person B" <[email protected]>

This is a multi-part message in MIME format.

------_=_NextPart_001_01D64658.43C8EDDA
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_002_01D64658.43C8EDDA"


------_=_NextPart_002_01D64658.43C8EDDA
Content-Type: text/plain;
	charset="UTF-8"
Content-Transfer-Encoding: base64

[BASE64_CODE]

------_=_NextPart_002_01D64658.43C8EDDA
Content-Type: text/html;
	charset="UTF-8"
Content-Transfer-Encoding: base64

[BASE64_CODE]

------_=_NextPart_002_01D64658.43C8EDDA--

------_=_NextPart_001_01D64658.43C8EDDA
Content-Type: image/jpeg;
	name="My image 1.jpg"
Content-Transfer-Encoding: base64
Content-ID: <ii_kbmfpvi21>
Content-Description: My image 1.jpg
Content-Disposition: inline;
	filename="My image 1.jpg"
Content-Location: My%20image%201.jpg

[BASE64_CODE]

------_=_NextPart_001_01D64658.43C8EDDA
Content-Type: image/png;
	name="My image 2.png"
Content-Transfer-Encoding: base64
Content-ID: <ii_15ede0d9eaf5a302>
Content-Description: My image 2.png
Content-Disposition: inline;
	filename="My image 2.png"
Content-Location: My%20image%202.png

[BASE64_CODE]

------

As mentioned, used the same approach as before in rcube_message.php:

                    // part belongs to a related message and is linked
                    // Note: mixed is not supposed to contain inline images, but we've found such examples (#5905)
                    if (preg_match('/^multipart\/(related|relative|mixed)/', $mimetype)
                        && ($mail_part->content_id || $mail_part->content_location)
                    ) {
                        $this->add_part($mail_part, 'inline');
+			$this->add_part($mail_part, 'attachment');
                    }

Maybe not the correct approach but somehow it still works on the cases I've come accross.

bohwaz added a commit to bohwaz/roundcubemail that referenced this issue Sep 21, 2023
@bohwaz
Copy link

bohwaz commented Sep 21, 2023

Thanks for the patch, I proposed a PR based on this patch: #9150

@bohwaz
Copy link

bohwaz commented Jan 27, 2024

@alecpl What kind of solution would be accepted? Or is this a won't fix?

bohwaz added a commit to bohwaz/roundcubemail that referenced this issue Jan 28, 2024
* In plaintext mode: all inline images will be displayed below the message body
* In HTML mode: all inline images that are **not** referenced in the message HTML body will be listed below the message body

This doesn't add more CPU usage as it is using the already called HTML filtering function to discover if an inline part is referenced or not.

This fixes issue roundcube#5051 and is a bit better than roundcube#9150
@bohwaz
Copy link

bohwaz commented Jan 28, 2024

@alecpl see #9326 for another option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants