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

[BUG] Long attachment names are truncated on rfc2231 email header #684

Open
christianasche opened this issue Nov 4, 2022 · 0 comments
Open
Labels
needs investigation This will be tested / debugged or checked out.

Comments

@christianasche
Copy link
Contributor

Environment (please complete the following information):

  • PHP IMAP version: 5.0.0
  • PHP Version: 8.x
  • Type of execution: Web Server

Describe the bug

Receiving email attachments with the following header creates incomplete filenames.

Content-Disposition: attachment;
	filename*0*="utf-8''A%20very%20very%20...%20";
	filename*1*="long%20filename.pdf"

The name property of the IncomingMailAttachment object should be
'A very very ... long filename.pdf', but instead is 'A very very ...'.
The part in filename1 is missing.

The filename is already truncated in der $params parameter of the
downloadAttachment() method.

Without further investigation, I think the cause could probably be in
line 1755 of src/PhpImap/Mailbox.php.

$paramName = \strtolower(\preg_match('~^(.*?)\*~', $param->attribute, $matches) ? (!isset($matches[1]) ?: $matches[1]) : $param->attribute);

Receiving email attachments with this type of header works as expected:

Content-Disposition: attachment;
	filename="A very very ... long filename.pdf"; ...
@christianasche christianasche added the needs investigation This will be tested / debugged or checked out. label Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This will be tested / debugged or checked out.
Projects
None yet
Development

No branches or pull requests

1 participant