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

Skip not requested parts #6543

Merged
merged 1 commit into from
May 27, 2022
Merged

Skip not requested parts #6543

merged 1 commit into from
May 27, 2022

Conversation

kesselb
Copy link
Contributor

@kesselb kesselb commented May 24, 2022

⚠️ Forwarding emails is broken in Mail 1.12. Please review this patch with Mail 1.11.

How to reproduce / test

  1. Sent a message to yourself with three attachments.
  2. Forward the message to yourself
  3. Note that in the forwarded message only the first attachment is correct, attachment two and three are 0 byte.

When forwarding a message

handleAttachments is calling getRawAttachments (via handleForwardedAttachment) for each attachment to forward. getRawAttachments get the attachment id (which references a mime part of the original message) as argument.

getRawAttachments fetch the structure for the message.
In a second query we request the actual body for the attachment (buildAttachmentsPartsQuery).

getRawAttachments for Attachment 1

image

getRawAttachments for Attachment 2

image

getRawAttachments for Attachment 3

image

We see in the $attachments array that attachment 1 is at position 0, attachment 2 at 1 and attachment 3 at 2. The reason is that $structure->partIterator() always returns all parts of a message regardless if mail request the data for it or not.

For example getRawAttachments for attachment 3 is also reading the data for attachment 1 and get an empty string because we do not request to fetch the data for it.

// Attaches attachment to new message
$message->addRawAttachment($attachment['fileName'], $attachments[0]);

In handleForwardedAttachment mail always uses the attachment at position 0 for the data. for attachment 3 we add the empty data for attachment 1.

This patch changes the behavior to skip parts we did not request.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Makes sense

@ChristophWurst
Copy link
Member

/backport to stable1.12

Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

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

Tested and works.

Tested on stable1.11 via git apply <(curl -fL https://github.com/nextcloud/mail/pull/6543.patch).

@st3iny st3iny merged commit f5a23c4 into main May 27, 2022
@st3iny st3iny deleted the bug/6064/forward-attachments branch May 27, 2022 12:54
@st3iny st3iny added this to the v1.13.0 milestone May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants