1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Properly parse email replies with varied 'To' address formats

Summary:
While my client and some others send email replies with an address like
##T1+x+y@example.com##, some other clients have sent either
##<T1+x+y@example.com>## or ##"T1+x+y@example.com" <T1+x+y@example.com>##.
Properly parse all the formats we've seen in the wild.

Test Plan:
Ran the regexp against all the formats observed in the wild (see
https://secure.phabricator.com/mail/received/) and verified it parses them
correctly.

Reviewed By: jungejason
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, aran, jungejason
Differential Revision: 370
This commit is contained in:
epriestley 2011-05-29 03:33:03 -07:00
parent 0238f260df
commit 0cdf4c2518

View file

@ -39,9 +39,12 @@ class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
public function processReceivedMail() { public function processReceivedMail() {
$to = idx($this->headers, 'to'); $to = idx($this->headers, 'to');
// Accept a match either at the beginning of the address or after an open
// angle bracket, as in:
// "some display name" <D1+xyz+asdf@example.com>
$matches = null; $matches = null;
$ok = preg_match( $ok = preg_match(
'/^((?:D|T)\d+)\+(\d+)\+([a-f0-9]{16})@/', '/(?:^|<)((?:D|T)\d+)\+(\d+)\+([a-f0-9]{16})@/U',
$to, $to,
$matches); $matches);