Open weierophinney opened 4 years ago
I have further delved into the source code.
The function public static function fromString($string, $EOL = self::EOL)
in Headers.php
which parses the full message in this case contains no condition for a break, so it is logical that the exception is thrown when the parser reaches the multipart message body.
I wonder how this bug could go unnoticed until now?
Originally posted by @abulhol at https://github.com/zendframework/zend-mail/issues/245#issuecomment-543100427
Any news on this?
@abulhol if you have a reproducer (test case), that would help pinning the bug down
@Ocramius I think I have described the issue in enough detail, and @weierophinney has already investigated it sufficiently (and pinned down the bug). I don't have time to write a test case, sorry.
@abulhol eh, then don't expect somebody else to have time/interest in trying to reproduce the problem in their local (and then CI) environment 😞
@abulhol you can at least include a .php snippet and .txt attachment of reproducer as attachments to the pull request. be sure it shows the problem when executed standalone.
ok @glensc I will see what I can do, thx.
@Ocramius @glensc Here you go with a fully working example, please let me know if it doesn't run on your side: https://github.com/abulhol/pop3test
Hey guys, I would appreciate some feedback after having made the effort to create a working example.
ping
i recently see dimilasr issue on glpi:
[2024-05-21 18:22:03] glpiphplog.CRITICAL: *** Uncaught Exception Laminas\Mail\Exception\RuntimeException: Line "--_00" does not match header format! in /var/www/glpi/vendor/laminas/laminas-mail/src/Headers.php at line 116
Backtrace :
vendor/laminas/laminas-mime/src/Decode.php:162 Laminas\Mail\Headers::fromString()
...r/laminas/laminas-mail/src/Storage/Pop3.php:105 Laminas\Mime\Decode::splitMessage()
...r/laminas/laminas-mail/src/Storage/Part.php:175 Laminas\Mail\Storage\Pop3->getRawContent()
...r/laminas/laminas-mail/src/Storage/Part.php:249 Laminas\Mail\Storage\Part->cacheContent()
...r/laminas/laminas-mail/src/Storage/Part.php:471 Laminas\Mail\Storage\Part->countParts()
src/MailCollector.php:1607 Laminas\Mail\Storage\Part->rewind()
src/MailCollector.php:1778 MailCollector->getRecursiveAttached()
src/MailCollector.php:1081 MailCollector->getAttached()
src/MailCollector.php:811 MailCollector->buildTicket()
src/MailCollector.php:1923 MailCollector->collect()
src/CronTask.php:1027 MailCollector::cronMailgate()
front/cron.php:82 CronTask::launch()
We are using zend-mail to fetch emails via POP3 and IMAP. For integration tests, we run an instance of Flying Rat (https://pypi.org/project/flyingrat/) to mock a mail server with POP3. We build multipart emails in Python using MIMEMultipart and send them to the server via smtplib (all standard code used there, nothing fancy).
Now when I try to fetch the emails in zend-mail via
getMessage()
, it fails with the following exception::I have tried to debug this and printed out the
$params
in Message.php_construct
. It looks to me like zend-mail is not able to parse the headers correctly because Flying Rat does not support theTOP
command and so the whole message is downloaded. Could this be a bug?Here is the full debug output of the
$params
::Originally posted by @abulhol at https://github.com/zendframework/zend-mail/issues/245