-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Reading mail fails if it has attachments with UTF-8 characters in filenames #7553
Comments
Could you paste the exact arguments used in |
/cc @weierophinney |
Yes, sure. $testContentType = new \Zend\Mail\Header\ContentType;
$testContentType->addParameter('name', 'Demo_skulptūra_Vecā_Jaunā.jpg'); The same exception |
@APaikens Values in headers MUST follow RFC 2822, which means only visible ASCII characters. If you supply values that are outside that range, you must encode them first. My question is: are you creating a mail message from an individual part? If so, we should likely add some logic to allow passing un-encoded characters to the headers, and then encode them on-the-fly when retrieving them. I need a full use case, however, before we look into anything like this. |
A little bit more details - i follow examples from this link: http://framework.zend.com/manual/current/en/modules/zend.mail.read.html My aim is to process email messages as files, not to send them again.
foreach (new RecursiveIteratorIterator($mail->getMessage(1)) as $part) { It stops at this point. I checked source email - to me it seems, that attachments are encoded correctly. Simple test case - sent myself empty email with small text file, named Bādsīmbols.txt Content-Type: text/plain; charset=US-ASCII; name="=?UTF-8?B?QsSBZHPEq21ib2xzLnR4dA==?=" But - reading that email using previously described method gives same error. To me it seems that there is some hook inside logic - correct header names get decoded and then again passed to headers objects, where it fails - because they are already decoded. |
Hi there again, created a gist with example - https://gist.github.com/APaikens/40641d977fd5f05fbbf5 |
I have problem with this too. @APaikens, have you found any solution? |
No, not yet |
Well |
Any solution? |
Fixed in 2.5.2 |
Works in 2.5.2 |
I have similar problems in ZF1. Full email below, that throws the exception when read and parsed with ZF. It was created with Thunderbid. Emails cannot be parsed, if they have attachments containing utf8 characters in the filnames. I'm using ZF 1.12.17 for me the exception is thrown in
the error is: the exception happens in
example here is a complete test email that throws the exception.
|
I'm reading mail from server, using IMAP storage.
Problems started to show after update to latest version - 2.4.2.
With 2.4.0 everything works as described in example: http://framework.zend.com/manual/current/en/modules/zend.mail.read.html
Seems that this is a bit different than #7501
Problems starts with getting parts of message:
foreach (new RecursiveIteratorIterator($mail->getMessage(1)) as $part) {
Everything gets read and decoded correctly, even headers with UTF-8, but at the end it doesn't pass new validation for only-ASCII characters.
\vendor\zendframework\zendframework\library\Zend\Mail\Header\ContentType.php:145
Message:
Invalid content-type parameter value detected
Stack trace:
#0 vendor\zendframework\zendframework\library\Zend\Mail\Header\ContentType.php(55): Zend\Mail\Header\ContentType->addParameter('name', 'Demo_skulpt??ra...')
...
Currently I'm out of ideas how to solve this
The text was updated successfully, but these errors were encountered: