Page MenuHomePhabricator

Fix an issue where generation of mail processing error email could fail in the presence of duplicate headers
ClosedPublic

Authored by epriestley on Jan 11 2016, 6:01 PM.
Tags
None
Referenced Files
F13254624: D14996.diff
Sat, May 25, 3:33 AM
F13251329: D14996.id.diff
Fri, May 24, 10:23 PM
F13241328: D14996.diff
Wed, May 22, 8:21 PM
F13234006: D14996.diff
Tue, May 21, 2:42 AM
F13212293: D14996.diff
Fri, May 17, 6:33 AM
F13200988: D14996.id36228.diff
Tue, May 14, 6:57 AM
F13199252: D14996.diff
Mon, May 13, 1:08 PM
F13182355: D14996.diff
Thu, May 9, 11:25 PM
Subscribers
None

Details

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.)

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Fix an issue where generation of mail processing error email could fail in the presence of duplicate headers.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.Jan 11 2016, 6:13 PM
This revision was automatically updated to reflect the committed changes.