zend-mime icon indicating copy to clipboard operation
zend-mime copied to clipboard

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

Open ftzdomino opened this issue 9 years ago • 2 comments

The following code illustrates the weirdness:

<?php

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

$str = '=?iso-8859-1?Q?Jorgen?= <[email protected]>,=?iso-8859-1?Q?Schmorgen?= <[email protected]>';
$header = iconv_mime_decode($str);

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

The output:

=?UTF-8?Q?Jorgen=20<[email protected]>,Schmorgen=20<[email protected]>?=

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.

ftzdomino avatar Apr 27 '16 22:04 ftzdomino

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

mleko avatar Sep 08 '16 14:09 mleko

This repository has been closed and moved to laminas/laminas-mime; a new issue has been opened at https://github.com/laminas/laminas-mime/issues/7.

weierophinney avatar Dec 31 '19 21:12 weierophinney