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)
Mon, Dec 9, 12:49 AM
Unknown Object (File)
Fri, Dec 6, 6:33 AM
Unknown Object (File)
Thu, Dec 5, 10:37 AM
Unknown Object (File)
Fri, Nov 29, 5:04 PM
Unknown Object (File)
Fri, Nov 29, 11:23 AM
Unknown Object (File)
Mon, Nov 25, 2:23 PM
Unknown Object (File)
Oct 30 2024, 10:57 PM
Unknown Object (File)
Oct 26 2024, 1:28 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
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.