imap icon indicating copy to clipboard operation
imap copied to clipboard

The method getAllContentsBySubtype treats html attachments as html body part

Open ThomasTr opened this issue 6 months ago • 1 comments

Q A
ddeboer/imap version 1.21.0
PHP version 8.3
IMAP provider Selfhosted

Summary

The method getAllContentsBySubtype treats html attachments as html body part. This method does not check whether it is an attachment.

Current behavior

Html attachments treated as html body part.

How to reproduce: code & error stack trace

These part is detected by method getAllContentsBySubtype as html part

Content-Disposition: attachment;
	filename=attachment.html
Content-Type: text/html;
	x-unix-mode=0644;
	name="attachment.html"
Content-Transfer-Encoding: quoted-printable

Expected behavior

Attachments should not be treated as html body parts.

This should detect attachments:

            if('attachment' === $part->getDisposition())
            {
                continue;
            }

above this code:

            if ($subtype === $part->getSubtype()) {
                $parts[] = $part->getDecodedContent();
            }

If it is okay I can provide a pull request.

ThomasTr avatar Jun 03 '25 12:06 ThomasTr

Hi, would you be so kind to propose a PR with a fix for this, including the needed tests?

Slamdunk avatar Jun 03 '25 12:06 Slamdunk