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

Check if attachment is actually(!) referred to #9585

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

pabzm
Copy link
Member

@pabzm pabzm commented Aug 15, 2024

This finishes what #9472 intended to do – but didn't actually do, as I found out.

The code now checks for each non-text mime-part in a multipart-part if its Content-ID or Content-Location is (probably) used in a sibling HTML-part, and only if that matches the respective mime-part is considered an "inline" attachment (that won't show up as downloadable or below the message content).

The second commit in this PR makes sure that for all image-parts, all mime-part-headers are loaded from the server, in order to actually get hands on the Content-Location-header (which isn't always fetched in the first place). It is limited to image-parts because those are the most common ones maybe having a Content-Location-header and I assumed that we shouldn't load the headers for every mime-part, so this seems like a workable real-world distinction for me.

One could probably change how the BODYSTRUCTURE response is fetched and parsed to ensure a Content-Location-header is always fetched in the first place, but I didn't dare to touch that code.

This fix closes #9565

@pabzm pabzm force-pushed the check-if-attachment-is-actually-referred-to branch from d9fe09b to 73cbc95 Compare August 15, 2024 13:41
@pabzm pabzm changed the title Check if attachment is actually referred to Check if attachment is actually(!) referred to Aug 15, 2024
@pabzm pabzm self-assigned this Aug 15, 2024
@pabzm pabzm force-pushed the check-if-attachment-is-actually-referred-to branch from 73cbc95 to 636dcdf Compare August 15, 2024 13:45
@pabzm pabzm requested a review from alecpl August 15, 2024 13:52
@pabzm pabzm force-pushed the check-if-attachment-is-actually-referred-to branch 2 times, most recently from 1373f57 to 8f12091 Compare November 12, 2024 10:08
Copy link

@pabzm, @alecpl
🛎️ This PR has had no activity in two weeks.

Copy link

@pabzm, @alecpl
🛎️ This PR has had no activity in two weeks.

@pabzm pabzm mentioned this pull request Dec 19, 2024
@pabzm pabzm marked this pull request as draft December 20, 2024 17:04
@pabzm pabzm force-pushed the check-if-attachment-is-actually-referred-to branch 2 times, most recently from 698570d to 321d1c6 Compare January 6, 2025 07:06
@pabzm
Copy link
Member Author

pabzm commented Jan 6, 2025

I would like to integrate a lot more messages into the "Message Rendering" tests, but the rest of the code is ready as it is, and I can supplement additional tests later, too.

@pabzm pabzm marked this pull request as ready for review January 6, 2025 13:30
@pabzm
Copy link
Member Author

pabzm commented Jan 7, 2025

@alecpl Could you have another look at this, please?

Copy link
Member

@alecpl alecpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need more time to properly test this.

@alecpl
Copy link
Member

alecpl commented Jan 12, 2025

I've tested a bit with various messages. I've found one regression: a forwarded message with eml attachment - there's a difference in displaying it with this patch and without. The attached message headers section is missing. Also if you open the eml attachment the headers will be missing.

ps. I noticed that we FETCH BODY.PEEK[2] for such messages, i.e. we fetch the whole attached message. It seems not optimal if it contains big attachments (I'd have to investigate that separately) - it's the same in release-1.6, so nothing new, I suppose.

@pabzm
Copy link
Member Author

pabzm commented Jan 15, 2025

I've found one regression: a forwarded message with eml attachment

Thank you for finding this! It's present in the "master" branch already, though. I'll try to find out which change is to blame and how to fix it.

@alecpl
Copy link
Member

alecpl commented Jan 15, 2025

I've found one regression: a forwarded message with eml attachment

Thank you for finding this! It's present in the "master" branch already, though. I'll try to find out which change is to blame and how to fix it.

It works fine in master.

@pabzm
Copy link
Member Author

pabzm commented Jan 15, 2025

It works fine in master.

I double-checked and still see the wrong behaviour on the lastest state of the "master"-branch.

I'm testing with the attached message, can you please check if it's displayed properly in your setup?

Fwd Lines.eml.zip

And can you provide me with your test message?

@alecpl
Copy link
Member

alecpl commented Jan 15, 2025

Ah, sorry. You're right. It works in release-1.6, but not in master. My bad.

@pabzm
Copy link
Member Author

pabzm commented Jan 15, 2025

This is what I see with Roundcubemail v1.6.9:

Screenshot RC 1.6.9

And this is what I see with Roundcubemail "master" branch:

Screenshot RC 'master' branch

@pabzm
Copy link
Member Author

pabzm commented Jan 15, 2025

The bug was introduced in c47accb from a year ago. Looks like a simple logic error. I made a fix for the problem – but applied to the latest "master", the problem still occurs, so there seems to be another code issue. I'l continue the search.

@pabzm
Copy link
Member Author

pabzm commented Jan 15, 2025

Actually my fix does fix the bug if I work thoroughly: #9753

pabzm added 2 commits January 16, 2025 10:21
If there's no reference to it in a sibling HTML part then we handle it
as a classic attachment (which is shown as downloadable).
Previously all headers were only fetched for message/rfc822, or
if the Content-Type's "name" parameter was set, or if a Content-ID was
set.
The RFC doesn't require neither the "name" parameter nor a Content-ID
for using Content-Location, though, so we shouldn't depend on those.

Instead now all headers are also fetched if the main part of the
Content-Type is "image", to catch more cases.
@pabzm pabzm force-pushed the check-if-attachment-is-actually-referred-to branch from 321d1c6 to 9d05bfe Compare January 16, 2025 09:23
@pabzm
Copy link
Member Author

pabzm commented Jan 16, 2025

Rebased onto the "master" branch to fix a conflict

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

Successfully merging this pull request may close these issues.

Attached picture is not shown if text-part is present in multipart/mixed and image-part as Content-ID
3 participants