Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

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

Open
ftzdomino opened this issue Apr 27, 2016 · 2 comments

Comments

@ftzdomino
Copy link

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:
zendframework/zend-mail#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.

@mleko
Copy link
Contributor

mleko commented Sep 8, 2016

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

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-mime; a new issue has been opened at laminas/laminas-mime#7.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants