Skip to content

Fix binary attachment and Content-Disposition header handling - #8

Merged
arukompas merged 3 commits into
opcodesio:mainfrom
jacekkow:main
Jun 11, 2026
Merged

Fix binary attachment and Content-Disposition header handling#8
arukompas merged 3 commits into
opcodesio:mainfrom
jacekkow:main

Conversation

@jacekkow

@jacekkow jacekkow commented May 22, 2026

Copy link
Copy Markdown
Contributor

While trying to use this library I have noticed two problems:

  1. Some binary attachments in S/MIME signed e-mail were rejected by the ASN.1 parser. It turns out that the 0x0D 0x0A byte sequence is unconditionally replaced by 0x0A. Solution: do not touch attachments, return their content as-is.

  2. Content-Disposition header is case-sensitive, even though relevant documentation states it must be case-insensitive. Solution: case fold value before comparison and add i flag to regexps.

jacekkow added 2 commits May 22, 2026 11:14
Binary files do not like to have 0x0D 0x0A replaced with 0x0A
Per RFC6266:

> If the disposition type matches "attachment" (case-insensitively) (...)

> The parameters "filename" and "filename*", to be matched case-insensitively (...)

@arukompas arukompas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for submission!

Can we please have some regression tests before merging: one for decoded attachment bytes containing \r\n, and one for uppercase Content-Disposition / filename parameters?

@jacekkow
jacekkow requested a review from arukompas June 11, 2026 08:36
@jacekkow

Copy link
Copy Markdown
Contributor Author

@arukompas Two tests have been added to MessageTest.php

@arukompas
arukompas merged commit 7151e41 into opcodesio:main Jun 11, 2026
@arukompas

Copy link
Copy Markdown
Contributor

New release tagged - https://github.com/opcodesio/mail-parser/releases/tag/v0.2.4

Thank you @jacekkow ! 🚀

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.

2 participants