laminas / laminas-mime

Create and parse MIME messages and parts
https://docs.laminas.dev/laminas-mime/
BSD 3-Clause "New" or "Revised" License
29 stars 23 forks source link

Mime::encodeQuotedPrintableHeader breaks Zend_Mail's parsing if encoding is needed and there are multiple recipients #7

Closed weierophinney closed 3 years ago

weierophinney commented 4 years ago

The following code illustrates the weirdness:

<?php

require_once __DIR__.'/vendor/autoload.php';
use Zend\Mime\Mime;

$str = '=?iso-8859-1?Q?Jorgen?= <foo1@example.com>,=?iso-8859-1?Q?Schmorgen?= <foo2@example.com>';
$header = iconv_mime_decode($str);

$encoded = Mime::encodeQuotedPrintableHeader($header, 'UTF-8', 78, "\r\n");
echo $encoded;

The output:

=?UTF-8?Q?Jorgen=20<foo1@example.com>,Schmorgen=20<foo2@example.com>?=

This is a problem now that zend-mail explodes the whole encoded string on a comma to due to this: https://github.com/zendframework/zend-mail/pull/44 Which results in the prefix and suffix being split up, breaking the parsing of the header.

The RFCs don't seem to be clear about whether the header field separator is allowed in the middle of a quoted-printable string, but do say that it should only be used if necessary for a given token.


Originally posted by @ftzdomino at https://github.com/zendframework/zend-mime/issues/12

weierophinney commented 4 years ago

According to https://tools.ietf.org/html/rfc2047#section-2 encoded strings are designed to be recognized as 'atom's by an RFC 822 parser

So separator is not allowed inside encoded string(but comma is)

BTW quoted printable name is misused here, you should split before decoding and combine after recoding


Originally posted by @mleko at https://github.com/zendframework/zend-mime/issues/12#issuecomment-245608918

weierophinney commented 3 years ago

This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee. If you have a security issue, please follow our security reporting guidelines. If you wish to take on the role of maintainer, please nominate yourself

If you are looking for an actively maintained package alternative, we recommend: