mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Fix an issue where generation of mail processing error email could fail in the presence of duplicate headers
Summary: Ref T10121. If a user sends mail with duplicate headers, like: ``` X-Duplicate: A X-Duplicate: B ``` ...and we process it with `mail_handler.php`, we may end up with `array('A', 'B')` as the header value. When we try to write this back into an error response mail, it fails. Test Plan: - Generated a message with duplicate headers. - Piped it into `mail_handler.php` with `--process-duplicates` and `--trace` to get a look at it. - Faked an exception. - Before patch: bad error email. - After patch: clean error email showing multiple header values. ``` $ ./bin/mail show-outbound --id 12386 PROPERTIES ID: 12386 Status: queued Related PHID: Message: PARAMETERS sensitive: 1 is-error: 1 force: 1 subject: Error Processing Mail (Exception) raw-to: ["epriestley@phacility.com"] HEADERS X-Phabricator-Sent-This-Message: Yes X-Mail-Transport-Agent: MetaMTA X-Auto-Response-Suppress: All TEXT BODY Your email to Phabricator was not processed, because an error occurred while trying to handle it: Exception: TEST -- Original Message Body ----------------------------------------------------- testy testy -- Original Message Headers -------------------------------------------------- from: Evan Priestley <epriestley@phacility.com> content-type: text/plain; charset=us-ascii content-transfer-encoding: 7bit x-smtp-server: smtp.gmail.com:epriestley@phacility.com subject: test outbound mail message-id: 7isvptmllqvdvtdxthvdwzg3woj5au7csyuh3hopypjv6y6hqb32qm4bcrd4jtid x-universally-unique-identifier: 4E489E20-F674-49B2-94BA-0DE44F504EAA date: Mon, 11 Jan 2016 09:50:12 -0800 date: Mon, 11 Jan 2016 09:50:13 -0800 date: Mon, 11 Jan 2016 09:50:14 -0800 date: Mon, 11 Jan 2016 09:50:15 -0800 to: epriestley@yghe.net mime-version: 1.0 (Mac OS X Mail 8.2 \(2104\)) HTML BODY (This message has no HTML body.) ``` Reviewers: chad Reviewed By: chad Maniphest Tasks: T10121 Differential Revision: https://secure.phabricator.com/D14996
This commit is contained in:
parent
a061bd2d09
commit
516ba5e6c5
1 changed files with 11 additions and 2 deletions
|
@ -327,9 +327,18 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
|||
// really be all the headers. It would be nice to pass the raw headers
|
||||
// through from the upper layers where possible.
|
||||
|
||||
// On the MimeMailParser pathway, we arrive here with a list value for
|
||||
// headers that appeared multiple times in the original mail. Be
|
||||
// accommodating until header handling gets straightened out.
|
||||
|
||||
$headers = array();
|
||||
foreach ($this->headers as $key => $value) {
|
||||
$headers[] = pht('%s: %s', $key, $value);
|
||||
foreach ($this->headers as $key => $values) {
|
||||
if (!is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
foreach ($values as $value) {
|
||||
$headers[] = pht('%s: %s', $key, $value);
|
||||
}
|
||||
}
|
||||
$headers = implode("\n", $headers);
|
||||
|
||||
|
|
Loading…
Reference in a new issue