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
Unknown Object (File)
May 29 2025, 2:31 PM
Unknown Object (File)
May 28 2025, 8:18 AM
Unknown Object (File)
May 10 2025, 1:21 PM
Unknown Object (File)
Apr 27 2025, 9:27 AM
Unknown Object (File)
Apr 22 2025, 2:03 PM
Unknown Object (File)
Apr 21 2025, 7:24 AM
Unknown Object (File)
Apr 20 2025, 9:03 AM
Unknown Object (File)
Mar 17 2025, 10:37 AM
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
Branch
maildupe1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 10061
Build 12178: Run Core Tests
Build 12177: arc lint + arc unit

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.